本文整理汇总了PHP中Modules::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Modules::count方法的具体用法?PHP Modules::count怎么用?PHP Modules::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Modules
的用法示例。
在下文中一共展示了Modules::count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register_module
/**
* Registers a module with the modules database table
* @param string $module
*/
public static function register_module($module)
{
$mod = new Modules();
$mod->getModuleByName($module);
if ($mod->count() == 0) {
// load the installer file
$file = "modules/{$module}/{$module}.install.php";
if (file_exists('sites/' . FabriqStack::site() . "/{$file}")) {
require_once 'sites/' . FabriqStack::site() . "/{$file}";
} else {
if (file_exists($file)) {
require_once $file;
} else {
throw new Exception("Module {$module} could not be found");
}
}
eval('$installer = new ' . $module . '_install();');
$info = $installer->info();
$mod->module = $module;
$mod->enabled = 0;
$mod->installed = 0;
$mod->hasconfigs = 0;
$mod->description = $info['description'];
$mod->versioninstalled = $info['version'];
if (isset($info['dependsOn'])) {
$mod->dependson = implode(',', $info['dependsOn']);
}
$mod->id = $mod->create();
// register configs if available
if (isset($info['configs'])) {
foreach ($info['configs'] as $con) {
$config = new ModuleConfigs();
$config->module = $mod->id;
$config->var = $con;
if (isset($info['configDefaults']) && array_key_exists($con, $info['configDefaults'])) {
$config->val = $info['configDefaults'][$con];
} else {
$config->val = '';
}
$config->create();
}
$mod->hasconfigs = 1;
$mod->update();
}
}
return $mod->id;
}
示例2: module_loaded
/**
* Returns true if module $name is installed and loaded
*
* @param string $name
* @return boolean
*/
function module_loaded($name)
{
static $cache = array();
if (!isset($cache[$name])) {
$cache[$name] = (bool) Modules::count(array('name = ?', $name));
}
// if
return $cache[$name];
}
示例3: paginate
/**
* Return paginated set of modules
*
* @param array $arguments
* @param itneger $page
* @param integer $per_page
* @return array
*/
function paginate($arguments = null, $page = 1, $per_page = 10)
{
if (!is_array($arguments)) {
$arguments = array();
}
// if
$arguments['limit'] = $per_page;
$arguments['offset'] = ($page - 1) * $per_page;
$modules = Modules::findBySQL(DataManager::prepareSelectFromArguments($arguments, TABLE_PREFIX . 'modules'), null, array_var($arguments, 'one'));
$total_modules = Modules::count(array_var($arguments, 'conditions'));
return array($modules, new Pager($page, $total_modules, $per_page));
}
示例4: isInstalled
/**
* Returns true if this module installed
*
* @param void
* @return boolean
*/
function isInstalled()
{
return (bool) Modules::count(array('name = ?', $this->name));
}