function mediashare_sourcesapi_scanSources() { // Check access if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $dom = ZLanguage::getModuleDomain('mediashare'); // Clear existing sources table if (!DBUtil::truncateTable('mediashare_sources')) { return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('sourcesapi.scanSources', __f("Could not clear the '%s' table.", 'sources', $dom)), $dom)); } // Scan for sources APIs $files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f'); foreach ($files as $file) { if (preg_match('/^pnsource_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) { $sourceName = $matches[1]; $sourceApi = "source_{$sourceName}"; // Force load - it is used during pninit pnModAPILoad('mediashare', $sourceApi, true); if (!($title = pnModAPIFunc('mediashare', $sourceApi, 'getTitle'))) { return false; } if (!pnModAPIFunc('mediashare', 'sources', 'addSource', array('title' => $title, 'name' => $sourceName))) { return false; } } } return true; }
/** * read editors folder and load names into array * * @param array $args * @return type */ public function getEditors($args) { $path = 'modules/Scribite/plugins'; $plugins = FileUtil::getFiles($path, false, true, null, 'd'); $editors = array(); foreach ($plugins as $pluginName) { $className = 'ModulePlugin_Scribite_' . $pluginName . '_Plugin'; $instance = PluginUtil::loadPlugin($className); $pluginstate = PluginUtil::getState($instance->getServiceId(), PluginUtil::getDefaultState()); if ($pluginstate['state'] == PluginUtil::ENABLED) { if (isset($args['format']) && $args['format'] == 'formdropdownlist') { $editors[] = array( 'text' => $instance->getMetaDisplayName(), 'value' => $pluginName ); } else { $editors[$pluginName] = $instance->getMetaDisplayName(); } } } return $editors; }
/** * Avatar_userapi_GetAvatars() * * returns all possible avatars for the current user. * * @param integer $args['uid'] the user ID (if missing, the current user is assumed) * @param integer $args['startnum'] int the number where to start (for paging) * @param integer $args['perpage'] int items per page * @return array a list of avatar file names **/ public function getAvatars($args) { $uid = isset($args['uid']) ? $args['uid'] : UserUtil::getVar('uid'); $page = isset($args['page']) ? $args['page'] : -1; $perpage = isset($args['perpage']) ? $args['perpage'] : -1; $realimages = isset($args['realimages']) ? true : false; $avatarpath = ModUtil::getVar('Users', 'avatarpath'); $allavatars = FileUtil::getFiles($avatarpath, true, true, null, false); if ($realimages == true) { $allavatars = array_diff($allavatars, array('blank.gif', 'gravatar.gif')); } $avatars = array(); foreach ($allavatars as $avatar) { // imagename is like pers_XXXX.gif (with XXXX = user id) if (ModUtil::apiFunc('Avatar', 'user', 'checkAvatar', array('avatar' => $avatar, 'uid' => $uid)) == true) { $avatars[] = $avatar; } } sort($avatars); $allcount = count($avatars); // paging if ($page != -1 && $perpage != -1) { $start = ($page - 1) * $perpage; $stop = $start + $perpage; if ($stop > $allcount) { $stop = $allcount; } $pagedavatars = array(); for ($idx = $start; $idx < $stop; $idx++) { $pagedavatars[] = $avatars[$idx]; } return array($pagedavatars, $allcount); } return array($avatars, $allcount); }
/** * Modify module Config */ public function modifyconfig() { $this->throwForbiddenUnless(SecurityUtil::checkPermission('Zgoodies::', '::', ACCESS_ADMIN), LogUtil::getErrorMsgPermission()); // Get module configuration vars $vars = $this->getVars(); if (!isset($vars['navgoco_save'])) { $vars['navgoco_save'] = 1; } if (!isset($vars['navgoco_accordion'])) { $vars['navgoco_accordion'] = 0; } if (!isset($vars['navgoco_caretHtml'])) { $vars['navgoco_caretHtml'] = ''; } if (!isset($vars['navgoco_openClass'])) { $vars['navgoco_openClass'] = ''; } if (!isset($vars['navgoco_slideduration'])) { $vars['navgoco_slideduration'] = ''; } if (!isset($vars['navgoco_slideeasing'])) { $vars['navgoco_slideeasing'] = ''; } if (!isset($vars['accmenu_eventType'])) { $vars['accmenu_eventType'] = 'click'; } if (!isset($vars['accmenu_skin'])) { $vars['accmenu_skin'] = 'grey.css'; } if (!isset($vars['accmenu_speed'])) { $vars['accmenu_speed'] = 'slow'; } if (!isset($vars['accmenu_saveState'])) { $vars['accmenu_saveState'] = 1; } if (!isset($vars['accmenu_autoClose'])) { $vars['accmenu_autoClose'] = 1; } if (!isset($vars['accmenu_autoExpand'])) { $vars['accmenu_autoExpand'] = 0; } if (!isset($vars['accmenu_showCount'])) { $vars['accmenu_showCount'] = 0; } if (!isset($vars['accmenu_hoverDelay'])) { $vars['accmenu_hoverDelay'] = 300; } // Javascript plugin skins $pluginskins = FileUtil::getFiles('javascript/jquery-plugins/accordion-menu/css/skins', false, true, null, 'f'); $this->view->assign('vars', $vars); $this->view->assign('pluginskins', $pluginskins); return $this->view->fetch('admin/modifyconfig.tpl'); }
/** * Scan the file system for modules. * * This function scans the file system for modules and returns an array with all (potential) modules found. * This information is used to regenerate the module list. * * @return array An array of modules found in the file system. */ public function getfilemodules() { // Security check if (!System::isInstalling()) { if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) { throw new \Zikula\Framework\Exception\ForbiddenException(); } } // Get all modules on filesystem $filemodules = array(); // set the paths to search $rootdirs = array('system' => ModUtil::TYPE_SYSTEM, 'modules' => ModUtil::TYPE_MODULE); foreach ($rootdirs as $rootdir => $moduletype) { if (is_dir($rootdir)) { $dirs = \FileUtil::getFiles($rootdir, false, true, null, 'd'); foreach ($dirs as $dir) { ZLoader::addModule($dir, $rootdir); // loads the gettext domain for 3rd party modules if ($rootdir == 'modules' && is_dir("modules/{$dir}/Resources/locale")) { ZLanguage::bindModuleDomain($dir); } try { $modversion = Util::getVersionMeta($dir, $rootdir); } catch (\Exception $e) { LogUtil::registerError($e->getMessage()); continue; } if (!isset($modversion['capabilities'])) { $modversion['capabilities'] = array(); } $name = $dir; // Work out if admin-capable if (class_exists("{$dir}\\Controller\\AdminController")) { $caps = $modversion['capabilities']; $caps['admin'] = array('version' => '1.0'); $modversion['capabilities'] = $caps; } // Work out if user-capable if (class_exists("{$dir}\\Controller\\UserController")) { $caps = $modversion['capabilities']; $caps['user'] = array('version' => '1.0'); $modversion['capabilities'] = $caps; } $version = $modversion['version']; $description = $modversion['description']; if (isset($modversion['displayname']) && !empty($modversion['displayname'])) { $displayname = $modversion['displayname']; } else { $displayname = $modversion['name']; } $capabilities = serialize($modversion['capabilities']); // bc for urls if (isset($modversion['url']) && !empty($modversion['url'])) { $url = $modversion['url']; } else { $url = $displayname; } if (isset($modversion['securityschema']) && is_array($modversion['securityschema'])) { $securityschema = serialize($modversion['securityschema']); } else { $securityschema = serialize(array()); } $core_min = isset($modversion['core_min']) ? $modversion['core_min'] : ''; $core_max = isset($modversion['core_max']) ? $modversion['core_max'] : ''; $oldnames = isset($modversion['oldnames']) ? $modversion['oldnames'] : ''; if (isset($modversion['dependencies']) && is_array($modversion['dependencies'])) { $moddependencies = serialize($modversion['dependencies']); } else { $moddependencies = serialize(array()); } $filemodules[$name] = array('directory' => $dir, 'name' => $name, 'type' => $moduletype, 'displayname' => $displayname, 'url' => $url, 'oldnames' => $oldnames, 'version' => $version, 'capabilities' => $capabilities, 'description' => $description, 'securityschema' => $securityschema, 'dependencies' => $moddependencies, 'core_min' => $core_min, 'core_max' => $core_max); // important: unset modversion and modtype, otherwise the // following modules will have some values not defined in // the next version files to be read unset($modversion); unset($modtype); } } } return $filemodules; }
/** * External applications */ function mediashare_editapi_extappGetApps($args) { $apps = array(); // Scan for application APIs $files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f'); foreach ($files as $file) { if (preg_match('/^pnextapp_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) { $apps[] = $matches[1]; } } return $apps; }
/** * Get all templates for a theme */ public function gettemplates($args) { // check our input if (!isset($args['theme']) || empty($args['theme'])) { return LogUtil::registerArgsError(); } $args['type'] = isset($args['type']) ? DataUtil::formatForOS($args['type']) : 'modules'; $themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($args['theme'])); $templatedir = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/templates'; if ($args['type'] == 'modules') { // for module templates also search on the theme/templates folder $templatelist = FileUtil::getFiles($templatedir, false, true, array('.tpl', '.htm'), 'f'); } else { $templatelist = array(); } $templatelist = array_merge($templatelist, FileUtil::getFiles($templatedir.'/'.$args['type'], false, $args['type'], array('.tpl', '.htm'), 'f')); return $templatelist; }
function mediashare_mediahandlerapi_scanMediaHandlers() { // Check access if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $dom = ZLanguage::getModuleDomain('mediashare'); // Clear existing handler table if (!DBUtil::truncateTable('mediashare_mediahandlers')) { return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('mediahandlerapi.scanMediaHandlers', __f("Could not clear the '%s' table.", 'mediahandlers', $dom)), $dom)); } // Scan for handlers APIs $files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f'); foreach ($files as $file) { if (preg_match('/^pnmedia_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) { $handlerName = $matches[1]; $handlerApi = "media_{$handlerName}"; // Force load - it is used during pninit pnModAPILoad('mediashare', $handlerApi, true); if (!($handler = pnModAPIFunc('mediashare', $handlerApi, 'buildHandler'))) { return false; } $fileTypes = $handler->getMediaTypes(); foreach ($fileTypes as $fileType) { $fileType['handler'] = $handlerName; $fileType['title'] = $handler->getTitle(); if (!pnModAPIFunc('mediashare', 'mediahandler', 'addMediaHandler', $fileType)) { return false; } } } } return true; }
/** * Get array of installed languages by code. * * @return array */ public static function getInstalledLanguages() { static $localeArray; if (isset($localeArray)) { return $localeArray; } // search for locale and config overrides $localeArray = array(); $search = array('config/locale', 'locale'); foreach ($search as $k) { // get only the directories of the search paths $locales = FileUtil::getFiles($k, false, true, null, 'd'); foreach ($locales as $locale) { $localeArray[] = self::transformInternal($locale); } } $localeArray = array_unique($localeArray); return $localeArray; }
/** * Scan the file system for modules. * * This function scans the file system for modules and returns an array with all (potential) modules found. * This information is used to regenerate the module list. * * @return array An array of modules found in the file system. */ public function getfilemodules() { // Security check if (!System::isInstalling()) { if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } } // Get all modules on filesystem $filemodules = array(); // set the paths to search $rootdirs = array('system' => ModUtil::TYPE_SYSTEM, 'modules' => ModUtil::TYPE_MODULE); foreach ($rootdirs as $rootdir => $moduletype) { if (is_dir($rootdir)) { $dirs = FileUtil::getFiles($rootdir, false, true, null, 'd'); foreach ($dirs as $dir) { $oomod = false; // register autoloader if (is_dir("{$rootdir}/{$dir}/lib")) { ZLoader::addAutoloader($dir, "{$rootdir}/{$dir}/lib"); $oomod = true; } // loads the gettext domain for 3rd party modules if ($rootdir == 'modules' && is_dir("modules/{$dir}/locale")) { // This is required here since including pnversion automatically executes the pnversion code // this results in $this->__() caching the result before the domain is bounded. Will not occur in zOO // since loading is self contained in each zOO application. ZLanguage::bindModuleDomain($dir); } try { $modversion = Extensions_Util::getVersionMeta($dir, $rootdir); } catch (Exception $e) { LogUtil::registerError($e->getMessage()); continue; } if (!isset($modversion['capabilities'])) { $modversion['capabilities'] = array(); } $name = $dir; // Get the module version if (!$modversion instanceof Zikula_AbstractVersion) { if (isset($modversion['profile']) && $modversion['profile']) { $modversion['capabilities']['profile'] = '1.0'; } if (isset($modversion['message']) && $modversion['message']) { $modversion['capabilities']['message'] = '1.0'; } // Work out if admin-capable if (file_exists("{$rootdir}/{$dir}/pnadmin.php") || is_dir("{$rootdir}/{$dir}/pnadmin")) { $modversion['capabilities']['admin'] = '1.0'; } // Work out if user-capable if (file_exists("{$rootdir}/{$dir}/pnuser.php") || is_dir("{$rootdir}/{$dir}/pnuser")) { $modversion['capabilities']['user'] = '******'; } } elseif ($oomod) { // Work out if admin-capable if (file_exists("{$rootdir}/{$dir}/lib/{$dir}/Controller/Admin.php")) { $caps = $modversion['capabilities']; $caps['admin'] = array('version' => '1.0'); $modversion['capabilities'] = $caps; } // Work out if user-capable if (file_exists("{$rootdir}/{$dir}/lib/{$dir}/Controller/User.php")) { $caps = $modversion['capabilities']; $caps['user'] = array('version' => '1.0'); $modversion['capabilities'] = $caps; } } $version = $modversion['version']; $description = $modversion['description']; if (isset($modversion['displayname']) && !empty($modversion['displayname'])) { $displayname = $modversion['displayname']; } else { $displayname = $modversion['name']; } $capabilities = serialize($modversion['capabilities']); // bc for urls if (isset($modversion['url']) && !empty($modversion['url'])) { $url = $modversion['url']; } else { $url = $displayname; } if (isset($modversion['securityschema']) && is_array($modversion['securityschema'])) { $securityschema = serialize($modversion['securityschema']); } else { $securityschema = serialize(array()); } $core_min = isset($modversion['core_min']) ? $modversion['core_min'] : ''; $core_max = isset($modversion['core_max']) ? $modversion['core_max'] : ''; $oldnames = isset($modversion['oldnames']) ? $modversion['oldnames'] : ''; if (isset($modversion['dependencies']) && is_array($modversion['dependencies'])) { $moddependencies = serialize($modversion['dependencies']); } else { $moddependencies = serialize(array()); } //if (!isset($args['name'])) { $filemodules[$name] = array('directory' => $dir, 'name' => $name, 'type' => $moduletype, 'displayname' => $displayname, 'url' => $url, 'oldnames' => $oldnames, 'version' => $version, 'capabilities' => $capabilities, 'description' => $description, 'securityschema' => $securityschema, 'dependencies' => $moddependencies, 'core_min' => $core_min, 'core_max' => $core_max); // important: unset modversion and modtype, otherwise the // following modules will have some values not defined in // the next version files to be read unset($modversion); unset($modtype); } } } return $filemodules; }
/** * modify block settings */ public function modify($blockinfo) { // get variable values from database $vars = BlockUtil::varsFromContent($blockinfo['content']); // installed languages $languages = ZLanguage::getInstalledLanguageNames(); // Javascript plugin data $plugindir = 'javascript/jquery-plugins/Nivo-Slider'; $pluginthemes = FileUtil::getFiles($plugindir . '/themes', false, true, null, 'd'); // set default values - block if (!isset($vars['block_template'])) { $vars['block_template'] = 'slider.tpl'; } if (!isset($vars['block_title']) || !is_array($vars['block_title'])) { $vars['block_title'] = array(); } foreach (array_keys($languages) as $lang) { if (!array_key_exists($lang, $vars['block_title'])) { $vars['block_title'][$lang] = ''; } } if (!isset($vars['block_wrap'])) { $vars['block_wrap'] = true; } // set default values - content if (!isset($vars['slider_content']) || !is_array($vars['slider_content'])) { $vars['slider_content'] = array(); } foreach (array_keys($languages) as $lang) { if (!array_key_exists($lang, $vars['slider_content'])) { $vars['slider_content'][$lang] = ''; } } if (!isset($vars['slider_htmlcaption']) || !is_array($vars['slider_htmlcaption'])) { $vars['slider_htmlcaption'] = array(); } foreach (array_keys($languages) as $lang) { if (!array_key_exists($lang, $vars['slider_htmlcaption'])) { $vars['slider_htmlcaption'][$lang] = ''; } } if (!isset($vars['slider_content_editor'])) { $vars['slider_content_editor'] = true; } if (!isset($vars['slider_theme'])) { $vars['slider_theme'] = 'default'; } if (!isset($vars['slider_effect'])) { $vars['slider_effect'] = 'random'; } if (!isset($vars['slider_slices'])) { $vars['slider_slices'] = 15; } if (!isset($vars['slider_boxCols'])) { $vars['slider_boxCols'] = 8; } if (!isset($vars['slider_boxRows'])) { $vars['slider_boxRows'] = 4; } if (!isset($vars['slider_animSpeed'])) { $vars['slider_animSpeed'] = 500; } if (!isset($vars['slider_pauseTime'])) { $vars['slider_pauseTime'] = 3000; } if (!isset($vars['slider_startSlide'])) { $vars['slider_startSlide'] = 0; } if (!isset($vars['slider_directionNav'])) { $vars['slider_directionNav'] = true; } if (!isset($vars['slider_controlNav'])) { $vars['slider_controlNav'] = true; } if (!isset($vars['slider_controlNavThumbs'])) { $vars['slider_controlNavThumbs'] = false; } if (!isset($vars['slider_pauseOnHover'])) { $vars['slider_pauseOnHover'] = true; } if (!isset($vars['slider_manualAdvance'])) { $vars['slider_manualAdvance'] = false; } if (!isset($vars['slider_randomStart'])) { $vars['slider_randomStart'] = false; } $this->view->assign('vars', $vars); $this->view->assign('bid', $blockinfo['bid']); $this->view->assign('languages', $languages); $this->view->assign('plugindir', $plugindir); $this->view->assign('pluginthemes', $pluginthemes); $this->view->assign('plugineffects', array('sliceDown', 'sliceDownLeft', 'sliceUp', 'sliceUpLeft', 'sliceUpDown', 'sliceUpDownLeft', 'fold', 'fade', 'random', 'slideInRight', 'slideInLeft', 'boxRandom', 'boxRain', 'boxRainReverse', 'boxRainGrow', 'boxRainGrowReverse')); return $this->view->fetch('blocks/slider_modify.tpl'); }
/** * Templates */ function mediashare_userapi_getAllTemplates() { $templates = array(); $sets = FileUtil::getFiles('modules/mediashare/pntemplates/Frontend', false, true, null, 'd'); if (file_exists('config/templates/mediashare/Frontend')) { $add = FileUtil::getFiles('config/templates/mediashare/Frontend', false, true, null, 'd'); $sets = array_merge($sets, $add); } foreach ($sets as $set) { $templates[] = array('title' => $set, 'value' => $set); } return $templates; }
/** * Smarty function to display an editable dynamic user data field. * * Example * {duditemmodify propattribute='avatar'} * * Example * {duditemmodify propattribute='realname' uid=$uid} * * Example * {duditemmodify item=$item} * * Parameters passed in via the $params array: * ------------------------------------------- * string item The Profile DUD item. * string uid User ID to display the field value for (-1 = do not load). * string class CSS class to assign to the table row/form row div (optional). * string proplabel Property label to display (optional overrides the preformated dud item $item). * string propattribute Property attribute to display. * string error Property error message. * * @param array $params All attributes passed to this function from the template. * @param object &$smarty Reference to the Zikula_View/Smarty object. * * @return string|boolean The results of the module function; empty string if the Profile module is not available; false if error. */ function smarty_function_duditemmodify($params, &$smarty) { extract($params); unset($params); if (!ModUtil::available('Profile')) { return ''; } if (!isset($item)) { if (isset($proplabel)) { $item = ModUtil::apiFunc('Profile', 'user', 'get', array('proplabel' => $proplabel)); } else if (isset($propattribute)) { $item = ModUtil::apiFunc('Profile', 'user', 'get', array('propattribute' => $propattribute)); } else { return false; } } if (!isset($item) || empty ($item)) { return false; } // detect if we are in the registration form $onregistrationform = false; // TODO - will these globals always be available? Is there a utility method out there somewhere to get these? global $module, $func; if (strtolower($module) == 'users' && strtolower($func) == 'register') { $onregistrationform = true; } // skip the field if not configured to be on the registration form if ($onregistrationform && !$item['prop_required']) { $dudregshow = ModUtil::getVar('Profile', 'dudregshow', array()); if (!in_array($item['prop_id'], $dudregshow)) { return ''; } } $dom = ZLanguage::getModuleDomain('Profile'); if (!isset($uid)) { $uid = UserUtil::getVar('uid'); } if (!isset($class) || !is_string($class)) { $class = ''; } if (isset($item['temp_propdata'])) { $uservalue = $item['temp_propdata']; } elseif ($uid >= 0) { // TODO - This is a bit of a hack for admin editing. Need to know if it is a reg. $user = UserUtil::getVars($uid); $isRegistration = UserUtil::isRegistration($uid); $uservalue = UserUtil::getVar($item['prop_attribute_name'], $uid, false, $isRegistration); // ($alias, $uid); } // try to get the DUD output if it's Third Party if ($item['prop_dtype'] != 1) { $output = ModUtil::apiFunc($item['prop_modname'], 'dud', 'edit', array('item' => $item, 'uservalue' => $uservalue, 'class' => $class)); if ($output) { return $output; } } $render = $smarty;//Zikula_View::getInstance('Profile', false, null, true); // assign the default values for the control $render->assign('class', $class); $render->assign('value', DataUtil::formatForDisplay($uservalue)); $render->assign('attributename', $item['prop_attribute_name']); $render->assign('proplabeltext', $item['prop_label']); $render->assign('note', $item['prop_note']); $render->assign('required', (bool)$item['prop_required']); $render->assign('error', isset($error) ? $error : ''); // Excluding Timezone of the generics if ($item['prop_attribute_name'] == 'tzoffset') { if (empty($uservalue)) { $uservalue = UserUtil::getVar('tzoffset') ? UserUtil::getVar('tzoffset') : System::getVar('timezone_offset'); } $tzinfo = DateUtil::getTimezones(); $render->assign('value', isset($tzinfo["$uservalue"]) ? "$uservalue" : null); $render->assign('selectmultiple', ''); $render->assign('listoptions', array_keys($tzinfo)); $render->assign('listoutput', array_values($tzinfo)); return $render->fetch('profile_dudedit_select.tpl'); } if ($item['prop_attribute_name'] == 'avatar') { // detect if it's the registration form to skip this if ($onregistrationform) { return ''; } // only shows a link to the Avatar module if available if (ModUtil::available('Avatar')) { // TODO Add a change-link to the admins // only shows the link for the own user if (UserUtil::getVar('uid') != $uid) { return ''; } $render->assign('linktext', __('Go to the Avatar manager', $dom)); $render->assign('linkurl', ModUtil::url('Avatar', 'user', 'main')); $output = $render->fetch('profile_dudedit_link.tpl'); // add a hidden input if this is required if ($item['prop_required']) { $output .= $render->fetch('profile_dudedit_hidden.tpl'); } return $output; } // display the avatar selector if (empty($uservalue)) { $uservalue = 'gravatar.gif'; } $render->assign('value', DataUtil::formatForDisplay($uservalue)); $avatarPath = ModUtil::getVar(Users_Constant::MODNAME, Users_Constant::MODVAR_AVATAR_IMAGE_PATH, Users_Constant::DEFAULT_AVATAR_IMAGE_PATH); $filelist = FileUtil::getFiles($avatarPath, false, true, array('gif', 'jpg', 'png'), 'f'); asort($filelist); $listoutput = $listoptions = $filelist; // strip the extension of the output list foreach ($listoutput as $k => $output) { $listoutput[$k] = $output;//substr($output, 0, strrpos($output, '.')); } $selectedvalue = $uservalue; // if (in_array($uservalue, $filelist)) { // $selectedvalue = $uservalue; // } $render->assign('value', $selectedvalue); $render->assign('selectmultiple', ''); $render->assign('listoptions', $listoptions); $render->assign('listoutput', $listoutput); return $render->fetch('profile_dudedit_select.tpl'); } switch ($item['prop_displaytype']) { case 0: // TEXT $type = 'text'; break; case 1: // TEXTAREA $type = 'textarea'; break; case 2: // CHECKBOX $type = 'checkbox'; $editlabel = array_splice(explode('@@', $item['prop_listoptions']), 0, 1); if (!empty($editlabel[0])) { $render->assign('proplabeltext', __($editlabel[0], $dom)); } break; case 3: // RADIO $type = 'radio'; $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); $render->assign('listoptions', array_keys($options)); $render->assign('listoutput', array_values($options)); break; case 4: // SELECT $type = 'select'; if (DataUtil::is_serialized($uservalue)) { $render->assign('value', unserialize($uservalue)); } // multiple flag is the first field $options = explode('@@', $item['prop_listoptions'], 2); $selectmultiple = $options[0] ? ' multiple="multiple"' : ''; $render->assign('selectmultiple', $selectmultiple); $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); $render->assign('listoptions', array_keys($options)); $render->assign('listoutput', array_values($options)); break; case 5: // DATE $type = 'date'; // gets the format to use $format = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); switch (trim(strtolower($format))) { case 'datelong': //! This is from the core domain (datelong) $format = __('%A, %B %d, %Y'); break; case 'datebrief': //! This is from the core domain (datebrief) $format = __('%b %d, %Y'); break; case 'datestring': //! This is from the core domain (datestring) $format = __('%A, %B %d @ %H:%M:%S'); break; case 'datestring2': //! This is from the core domain (datestring2) $format = __('%A, %B %d'); break; case 'datetimebrief': //! This is from the core domain (datetimebrief) $format = __('%b %d, %Y - %I:%M %p'); break; case 'datetimelong': //! This is from the core domain (datetimelong) $format = __('%A, %B %d, %Y - %I:%M %p'); break; case 'timebrief': //! This is from the core domain (timebrief) $format = __('%I:%M %p'); break; case 'timelong': //! This is from the core domain (timelong) $format = __('%T %p'); break; } //! This is from the core domain (datebrief) $format = !empty($format) ? $format : __('%b %d, %Y'); // process the temporal data if any $timestamp = null; if (isset($item['temp_propdata'])) { $timestamp = DateUtil::parseUIDate($item['temp_propdata']); $uservalue = DateUtil::transformInternalDate($timestamp); } elseif (!empty($uservalue)) { $timestamp = DateUtil::makeTimestamp($uservalue); } $render->assign('value', $uservalue); $render->assign('timestamp', $timestamp); $render->assign('dudformat', $format); break; case 6: // EXTDATE (deprecated) // TODO [deprecate completely] $type = 'hidden'; break; case 7: // MULTICHECKBOX $type = 'multicheckbox'; $render->assign('value', (array)unserialize($uservalue)); $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); $render->assign('fields', $options); break; default: // TEXT $type = 'text'; break; } return $render->fetch('profile_dudedit_'.$type.'.tpl'); }
/** * Regenerates the theme list. */ public static function regenerate() { // Get all themes on filesystem $filethemes = array(); ModUtil::dbInfoLoad('Themes', 'Themes', true); if (is_dir('themes')) { $dirArray = FileUtil::getFiles('themes', false, true, null, 'd'); foreach ($dirArray as $dir) { // Work out the theme type if (file_exists("themes/$dir/version.php") && !file_exists("themes/$dir/theme.php")) { $themetype = 3; } else { // anything else isn't a theme continue; } // Get some defaults in case we don't have a theme version file $themeversion['name'] = preg_replace('/_/', ' ', $dir); $themeversion['displayname'] = preg_replace('/_/', ' ', $dir); $themeversion['version'] = '0'; $themeversion['description'] = ''; // include the correct version file based on theme type and // manipulate the theme version information if (file_exists($file = "themes/$dir/version.php")) { if (!include($file)) { LogUtil::registerError(__f('Error! Could not include theme version file: %s', $file)); } } $filethemes[$themeversion['name']] = array('directory' => $dir, 'name' => $themeversion['name'], 'type' => $themetype, 'displayname' => (isset($themeversion['displayname']) ? $themeversion['displayname'] : $themeversion['name']), 'version' => (isset($themeversion['version']) ? $themeversion['version'] : '1.0'), 'description' => (isset($themeversion['description']) ? $themeversion['description'] : $themeversion['displayname']), 'admin' => (isset($themeversion['admin']) ? (int)$themeversion['admin'] : '0'), 'user' => (isset($themeversion['user']) ? (int)$themeversion['user'] : '******'), 'system' => (isset($themeversion['system']) ? (int)$themeversion['system'] : '0'), 'state' => (isset($themeversion['state']) ? $themeversion['state'] : ThemeUtil::STATE_ACTIVE), 'contact' => (isset($themeversion['contact']) ? $themeversion['contact'] : ''), 'xhtml' => (isset($themeversion['xhtml']) ? (int)$themeversion['xhtml'] : 1)); // important: unset themeversion otherwise all following themes will have // at least the same regid or other values not defined in // the next version.php files to be read unset($themeversion); unset($themetype); } } // Get all themes in DB $dbthemes = DBUtil::selectObjectArray('themes', '', '', -1, -1, 'name'); // See if we have lost any themes since last generation foreach ($dbthemes as $name => $themeinfo) { if (empty($filethemes[$name])) { // delete a running configuration ModUtil::apiFunc('Theme', 'admin', 'deleterunningconfig', array('themename' => $name)); $result = DBUtil::deleteObjectByID('themes', $name, 'name'); unset($dbthemes[$name]); } } // See if we have gained any themes since last generation, // or if any current themes have been upgraded foreach ($filethemes as $name => $themeinfo) { if (empty($dbthemes[$name])) { // New theme $themeinfo['state'] = ThemeUtil::STATE_ACTIVE; DBUtil::insertObject($themeinfo, 'themes', 'id'); } } // see if any themes have changed foreach ($filethemes as $name => $themeinfo) { if (isset($dbthemes[$name])) { if (($themeinfo['directory'] != $dbthemes[$name]['directory']) || ($themeinfo['type'] != $dbthemes[$name]['type']) || ($themeinfo['admin'] != $dbthemes[$name]['admin']) || ($themeinfo['user'] != $dbthemes[$name]['user']) || ($themeinfo['system'] != $dbthemes[$name]['system']) || ($themeinfo['state'] != $dbthemes[$name]['state']) || ($themeinfo['contact'] != $dbthemes[$name]['contact']) || ($themeinfo['xhtml'] != $dbthemes[$name]['xhtml'])) { $themeinfo['id'] = $dbthemes[$name]['id']; DBUtil::updateObject($themeinfo, 'themes'); } } } return true; }
/** * Utility function to return a list of template sets for * displaying the comments input/output * * @return array array of template set names (directories) */ public function gettemplates() { if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_READ)) { return false; } $modinfo = ModUtil::getInfo(ModUtil::getIdFromName('EZComments')); $osmoddir = DataUtil::formatForOS($modinfo['directory']); $ostheme = DataUtil::formatForOS(UserUtil::getTheme()); $rootdirs = array("modules/$osmoddir/templates/", "config/templates/$osmoddir/", "themes/$ostheme/templates/$osmoddir/"); $templates = array(); // read each directory for template sets foreach ($rootdirs as $rootdir) { $folders = FileUtil::getFiles($rootdir, false, true, null, 'd'); foreach ($folders as $folder) { if (!in_array($folder, array('plugins'))) { $templates[] = $folder; } } } // return a list with no duplicates return array_unique($templates); }
/** * Clear CSS/JS combination cached files. * * Using this function, the user can clear all CSS/JS combination cached * files for the system. * * @return boolean */ public function clear_cssjscombinecache() { $cache_dir = $this->cache_dir; $cached_files = FileUtil::getFiles($cache_dir, true, false, array('php'), null, false); foreach ($cached_files as $cf) { unlink(realpath($cf)); } // The configuration has been changed, so we clear all caches. // clear Zikula_View_Theme cache self::clear_all_cache(); // clear Zikula_View cache (really needed?) Zikula_View::getInstance()->clear_all_cache(); return true; }
/** * Migration functionality * * This function provides a common interface to migration scripts. * The migration scripts will upgrade from different other modules * (like NS-Comments, Reviews, My_eGallery, ...) to EZComments. * * @return output the migration interface */ public function migrate() { if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $migrated = $this->getVar('migrated'); $available = FileUtil::getFiles('modules/EZComments/migrateapi', false, true, 'php', 'f'); $selectitems = array(); foreach ($available as $f) { $f = substr($f, 0, -4); if (!isset($migrated[$f]) || !$migrated[$f]) { $selectitems[$f] = $f; } } if (!$selectitems) { LogUtil::registerStatus($this->__('No migration plugins available.')); return System::redirect(ModUtil::url('EZComments', 'admin')); } // assign the migratation options $this->view->assign('selectitems', $selectitems); // Return the output that has been generated by this function return $this->view->fetch('ezcomments_admin_migrate.tpl'); }
/** * Loader for custom handlers. * * @param string $dir Path to the folder holding the eventhandler classes. * * @return void */ public function attachHandlers($dir) { $dir = realpath($dir); // only ever scan a directory once at runtime (even if Core is restarted). if (!isset($this->scannedDirs[$dir])) { $it = FileUtil::getFiles($dir, false, false, 'php', 'f'); foreach ($it as $file) { $before = get_declared_classes(); include realpath($file); $after = get_declared_classes(); $diff = new ArrayIterator(array_diff($after, $before)); if (count($diff) > 1) { while ($diff->valid()) { $className = $diff->current(); $diff->next(); } } else { $className = $diff->current(); } if (!isset($this->directoryContents[$dir])) { $this->directoryContents[$dir] = array(); } $this->directoryContents[$dir][] = $className; } $this->scannedDirs[$dir] = true; } if (!isset($this->attachedHandlers[$dir]) && isset($this->directoryContents[$dir])) { foreach ($this->directoryContents[$dir] as $className) { $this->attachEventHandler($className); $this->attachedHandlers[$dir] = true; } } }
public static function getStylesheets() { $stylesheets = array(); $styles = array(); // restricted stylesheets, array for possible future changes $sysStyles = array('system/Blocks/style/menutree/adminstyle.css', 'system/Blocks/style/menutree/contextmenu.css', 'system/Blocks/style/menutree/tree.css'); // module stylesheets $modulesStyles = FileUtil::getFiles('system/Blocks/style/menutree', false, false, 'css', false); $configStyles = FileUtil::getFiles('config/style/Blocks/menutree', false, false, 'css', false); $styles['modules'] = array_merge($modulesStyles, $configStyles); // themes stylesheets - get user and admin themes $userThemes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER); $adminThemes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_ADMIN); $themesStyles = array(); foreach ($userThemes as $ut) { $themesStyles[$ut['name']] = FileUtil::getFiles('themes/' . $ut['name'] . '/style/Blocks/menutree', false, false, 'css', false); } foreach ($adminThemes as $at) { if (!array_key_exists($at['name'], $themesStyles)) { $themesStyles[$at['name']] = FileUtil::getFiles('themes/' . $at['name'] . '/style/Blocks/menutree', false, false, 'css', false); } } // get stylesheets which exist in every theme $styles['themes']['all'] = call_user_func_array('array_intersect', $themesStyles); // get stylesheets which exist in some themes $styles['themes']['some'] = array_unique(call_user_func_array('array_merge', $themesStyles)); $styles['themes']['some'] = array_diff($styles['themes']['some'], $styles['themes']['all'], $styles['modules'], $sysStyles); $stylesheets = array_unique(array_merge($styles['modules'], $styles['themes']['all'])); $stylesheets = array_diff($stylesheets, $sysStyles); sort($stylesheets); // fill array keys using values $stylesheets = array_combine($stylesheets, $stylesheets); $someThemes = __('Only in some themes'); if (!empty($styles['themes']['some'])) { sort($styles['themes']['some']); $stylesheets[$someThemes] = array_combine($styles['themes']['some'], $styles['themes']['some']); } return self::normalize($stylesheets); }
/** * Discover all system plugins. * * @return array Array of plugin paths. */ public static function getAllSystemPlugins() { return FileUtil::getFiles('plugins', false, false, null, 'd'); }
/** * Deletes an existing upload file. * For images the thumbnails are removed, too. * * @param string $objectType Currently treated entity type. * @param string $objectData Object data array. * @param string $fieldName Name of upload field. * * @return mixed Array with updated object data on success, else false. */ public function deleteUploadFile($objectType, $objectData, $fieldName) { if (!in_array($objectType, $this->allowedObjectTypes)) { return false; } if (empty($objectData[$fieldName])) { return $objectData; } // determine file system information $basePath = MUBoard_Util_Controller::getFileBaseFolder($objectType, $fieldName); $fileName = $objectData[$fieldName]; // remove original file if (!unlink($basePath . $fileName)) { return false; } $objectData[$fieldName] = ''; $objectData[$fieldName . 'Meta'] = array(); $fileExtension = FileUtil::getExtension($fileName, false); if (!in_array($fileExtension, $this->imageFileTypes)) { // we are done, so let's return return $objectData; } // get extension again, but including the dot $fileExtension = FileUtil::getExtension($fileName, true); $thumbFileNameBase = str_replace($fileExtension, '', $fileName) . '_tmb_'; $thumbFileNameBaseLength = strlen($thumbFileNameBase); // remove image thumbnails $thumbPath = $basePath . 'tmb/'; $thumbFiles = FileUtil::getFiles($thumbPath, false, true, null, 'f'); // non-recursive, relative pathes foreach ($thumbFiles as $thumbFile) { $thumbFileBase = substr($thumbFile, 0, $thumbFileNameBaseLength); if ($thumbFileBase != $thumbFileNameBase) { // let other thumbnails untouched continue; } unlink($thumbPath . $thumbFile); } return $objectData; }