/** * Datasource constructor, creates the Configuration, Connection and DocumentManager objects * * ### You can pass the following configuration options * * - server: name of the server that will be used to connect to Mongo (default: `localhost`) * - database: name of the database to use when connecting to Mongo (default: `cake`) * - documentPaths: array containing a list of full path names where Document classes can be located (default: `App::path('Model')`) * - proxyDir: full path to the directory that will contain the generated proxy classes for each document (default: `TMP . 'cache'`) * - proxyNamespace: string representing the namespace the proxy classes will reside in (default: `Proxies`) * - hydratorDir: directory well the hydrator classes will be generated in (default: `TMP . 'cache'`) * - hydratorNamespace: string representing the namespace the hydrator classes will reside in (default: `Hydrators`) * * @param arary $config * @param boolean $autoConnect whether this object should attempt connection on creation * @throws MissingConnectionException if it was not possible to connect to MongoDB */ public function __construct($config = array(), $autoConnect = true) { $modelPaths = $this->_cleanupPaths(App::path('Model')); $this->_baseConfig = array('proxyDir' => TMP . 'cache', 'proxyNamespace' => 'Proxies', 'hydratorDir' => TMP . 'cache', 'hydratorNamespace' => 'Hydrators', 'server' => 'localhost', 'database' => 'cake', 'documentPaths' => $modelPaths, 'prefix' => null); foreach (CakePlugin::loaded() as $plugin) { $this->_baseConfig['documentPaths'] = array_merge($this->_baseConfig['documentPaths'], $this->_cleanupPaths(App::path('Model', $plugin))); } parent::__construct($config); extract($this->config, EXTR_OVERWRITE); $configuration = new Configuration(); $configuration->setProxyDir($proxyDir); $configuration->setProxyNamespace($proxyNamespace); $configuration->setHydratorDir($hydratorDir); $configuration->setHydratorNamespace($hydratorNamespace); $configuration->setDefaultDB($database); $configuration->setMetadataDriverImpl($this->_getMetadataReader($documentPaths)); if (Configure::read('debug') === 0) { $configuration->setAutoGenerateHydratorClasses(false); $configuration->setAutoGenerateProxyClasses(false); $configuration->setMetadataCacheImpl(new ApcCache()); } $this->configuration = $configuration; $this->connection = new Connection($server, array(), $configuration); $this->documentManager = DocumentManager::create($this->connection, $configuration); $this->documentManager->getEventManager()->addEventListener(array(Events::prePersist, Events::preUpdate, Events::preRemove, Events::postPersist, Events::postUpdate, Events::postRemove), $this); try { if ($autoConnect) { $this->connect(); } } catch (Exception $e) { throw new MissingConnectionException(array('class' => get_class($this))); } $this->setupLogger(); }
public function admin_index() { if ($this->request->is('post') && isset($this->request->data)) { $models = $this->request->data['Audit']['models']; $models = array_combine(array_values($models), array_values($models)); $this->Setting->write('Audit.models', json_encode($models)); return $this->redirect(array('action' => 'index')); } $plugins = App::objects('plugin'); $models = array(); $cakePlugin = new CakePlugin(); foreach ($plugins as $plugin) { if (!$cakePlugin->loaded($plugin)) { continue; } $pluginModels = App::objects($plugin . '.Model'); foreach ($pluginModels as $pluginModel) { if (substr($pluginModel, -8) == 'AppModel') { continue; } $model = $plugin . '.' . $pluginModel; $models[$model] = $model; } } $this->request->data = array('Audit' => array('models' => json_decode(Configure::read('Audit.models'), true))); $this->set(compact('models')); }
public function update() { if ($this->type == 'app') { $plugins = CakePlugin::loaded(); } else { $plugins[] = $this->type; } $this->out(__d('cake_console', '<info>-- Migration status in app --</info>')); $this->dispatchShell('Migrations.migration status -i ' . $this->connection); $this->hr(1, 100); if ($this->type == 'app') { $this->out(__d('cake_console', '<info>-- Application core database migrations --</info>')); $this->dispatchShell('Migrations.migration run all -i ' . $this->connection); $this->out(__d('cake_console', '<info>- Application core database updated</info>')); $this->hr(1, 100); } foreach ($plugins as $plugin) { $plugin_migration_folder = new Folder(CakePlugin::path($plugin) . 'Config' . DS . 'Migration'); list($m_folders, $m_files) = $plugin_migration_folder->read(true, array('empty')); if (count($m_files)) { $this->out(__d('cake_console', '<info>-- %s plugin database migrations</info>', $plugin)); $this->dispatchShell('migration run all --plugin ' . $plugin . ' -i ' . $this->connection); $this->out(__d('cake_console', '<info>- %s plugin database updated</info>', $plugin)); $this->hr(1, 100); } } $this->out(__d('cake_console', '<info>-- Build static assets --</info>')); $this->dispatchShell('AssetCompress.AssetCompress build -f'); $this->hr(1, 100); $this->out(__d('cake_console', '<warning>All done</warning>')); }
/** * AppController::constructClasses() * * @return void */ public function constructClasses() { if (CakePlugin::loaded('DebugKit')) { $this->components[] = 'DebugKit.Toolbar'; } parent::constructClasses(); }
public function testIs() { $result = Reveal::is('App.online'); $expected = !in_array(gethostbyname('google.com'), array('google.com', false)); $this->assertEqual($result, $expected); $result = Reveal::is('DebugKit.loaded'); $expected = CakePlugin::loaded('DebugKit'); $this->assertEqual($result, $expected); $result = Reveal::is(array('OR' => array('DebugKit.enabled', 'DebugKit.automated'))); $expected = Configure::read('debug') || Configure::read('DebugKit.forceEnable') || Configure::read('DebugKit.autoRun'); $this->assertEqual($result, $expected); $_GET['debug'] = 'true'; $this->assertTrue(Reveal::is('DebugKit.requested')); $result = Reveal::is('DebugKit.loaded', array('OR' => array('DebugKit.enabled', array('AND' => array('DebugKit.automated', 'DebugKit.requested'))))); $expected = CakePlugin::loaded('DebugKit') || Configure::read('debug') || Configure::read('DebugKit.forceEnable') || Configure::read('DebugKit.autoRun') && isset($_GET['debug']) && 'true' == $_GET['debug']; $this->assertEqual($result, $expected); $this->assertEqual(Reveal::is('DebugKit.running'), $expected); $request = new CakeRequest(); Router::setRequestInfo($request->addParams(array('controller' => 'pages', 'action' => 'display', 'pass' => array('home')))); $result = Reveal::is('Page.front'); $this->assertTrue($result); Router::reload(); $request = new CakeRequest(); Router::setRequestInfo($request->addParams(array('prefix' => 'admin', 'admin' => true))); $result = Reveal::is('Page.prefixed'); $this->assertTrue($result); Router::reload(); $request = new CakeRequest(); Router::setRequestInfo($request->addParams(array('controller' => 'users', 'action' => 'login'))); $result = Reveal::is('Page.login'); $this->assertTrue($result); $this->assertTrue(Reveal::is('Page.test')); }
/** * Get a list of plugins on construct for later use */ public function __construct() { foreach (CakePlugin::loaded() as $plugin) { $this->_pluginPaths[$plugin] = CakePlugin::path($plugin); } parent::__construct(); }
/** * Overwrite shell initialize to dynamically load all Queue Related Tasks. * * @return void */ public function initialize() { $paths = App::path('Console/Command/Task'); foreach ($paths as $path) { $Folder = new Folder($path); $res = array_merge($this->tasks, $Folder->find('Queue.*\\.php')); foreach ($res as &$r) { $r = basename($r, 'Task.php'); } $this->tasks = $res; } $plugins = CakePlugin::loaded(); foreach ($plugins as $plugin) { $pluginPaths = App::path('Console/Command/Task', $plugin); foreach ($pluginPaths as $pluginPath) { $Folder = new Folder($pluginPath); $res = $Folder->find('Queue.*Task\\.php'); foreach ($res as &$r) { $r = $plugin . '.' . basename($r, 'Task.php'); } $this->tasks = array_merge($this->tasks, $res); } } parent::initialize(); $this->QueuedTask->initConfig(); }
/** * Generates the base path to a set of tests based on the parameters. * * @param array $params * @return string The base path. */ protected static function _basePath($params) { $result = null; if (!empty($params['core'])) { $result = CORE_TEST_CASES; // CUSTOMIZE ADD 2014/07/02 ryuring // >>> } elseif ($params['baser']) { $result = BASER_TEST_CASES; // <<< } elseif (!empty($params['plugin'])) { if (!CakePlugin::loaded($params['plugin'])) { try { CakePlugin::load($params['plugin']); $result = CakePlugin::path($params['plugin']) . 'Test' . DS . 'Case'; } catch (MissingPluginException $e) { } } else { $result = CakePlugin::path($params['plugin']) . 'Test' . DS . 'Case'; } } elseif (!empty($params['app'])) { $result = APP_TEST_CASES; } return $result; }
public function main() { $wsdl = $path = $plugin = null; while (!$wsdl) { $wsdl = $this->in('Enter the url of the wsdl'); } while (!$path) { $path = $this->in('Save to App or a plugin?', array('app', 'plugin')); } if ($path == 'plugin') { $loaded = CakePlugin::loaded(); while (!$plugin) { $plugin = $this->in('Select plugin', $loaded); if (!in_array($plugin, $loaded)) { $plugin = null; } } $path = CakePlugin::path($plugin) . 'Lib'; $plugin .= '.'; } else { $path = APP . 'Lib'; } $wsdlInterpreter = new WSDLInterpreter($wsdl); $return = $wsdlInterpreter->savePHP($path); $path .= DS; $file = str_replace($path, '', $return[0]); $class = substr($file, 0, -4); $this->hr(); $this->out('Lib saved to:' . $path . $file); $text = "'lib' => '" . $plugin . $class . "'"; $this->out("Add 'lib' key to the config in database.php: " . $text); $this->hr(); }
/** * testHomeRoute */ public function testHomeRoute() { $promoted = array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'promoted'); $result = CroogoRouter::connect('/', $promoted); $translateLoaded = CakePlugin::loaded('Translate'); $expected = $translateLoaded ? 2 : 1; $this->assertEquals($expected, count($result)); $this->assertNotEmpty($result[0]); $this->assertInstanceOf('CakeRoute', $result[0]); $reversed = Router::parse('/'); $this->assertEquals($promoted, array_intersect_key($promoted, $reversed)); // another route $index = array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'index'); $result = CroogoRouter::connect('/nodes', $index); $expected = $translateLoaded ? 4 : 2; $this->assertEquals($expected, count($result)); $reversed = Router::parse('/'); $this->assertEquals($promoted, array_intersect_key($promoted, $reversed)); $terms = array('plugin' => 'nodes', 'controller' => 'nodes', 'action' => 'terms'); $result = CroogoRouter::connect('/', $terms); $expected = $translateLoaded ? 6 : 3; $this->assertEquals($expected, count($result)); // override '/' route Router::promote(); $reversed = Router::parse('/'); $this->assertEquals($terms, array_intersect_key($terms, $reversed)); }
/** * The migrate command. * * @return bool */ public function migrate() { $options = array('direction' => $this->args[0], 'scope' => 'app'); if (isset($this->params['plugin']) && CakePlugin::loaded($this->params['plugin'])) { $options['scope'] = $this->params['plugin']; } if (isset($this->args[1])) { $options['steps'] = (int) $this->args[1]; } try { $migrations = new Migrations($this->params['connection']); $migrations->migrate($options); } catch (Exception $e) { $this->out(__d('migration_shell', 'An error occured during the migration.')); $this->err($e->getMessage()); return false; } $this->out(__d('migration_shell', 'The migration was successful.')); /** @var SchemaMigration $sm */ $sm = ClassRegistry::init('Migrations.SchemaMigration'); $sm->setDataSource($this->params['connection']); $this->out(__d('migration_shell', 'Current Migration version: %s', array($sm->getCurrentVersion($options['scope'])))); $migrations->clearCache(); return true; }
/** * Take care of any minifying requests. * The import is not defined outside the class to avoid errors if the class is read from the console. * * @return void */ public function index($type) { $files = array_unique(explode(',', $_GET['f'])); $plugins = array(); $symLinks = array(); $newFiles = array(); if (!empty($this->request->base)) { $symLinks['/' . $this->request->base] = WWW_ROOT; } foreach ($files as &$file) { if (empty($file)) { continue; } $plugin = false; list($first, $second) = pluginSplit($file); if (CakePlugin::loaded($first) === true) { $file = $second; $plugin = $first; } $pluginPath = !empty($plugin) ? '../Plugin/' . $plugin . '/' . WEBROOT_DIR . '/' : ''; $file = $pluginPath . $type . '/' . $file . '.' . $type; $newFiles[] = $file; if (!empty($plugin) && !isset($plugins[$plugin])) { $plugins[$plugin] = true; $symLinks['/' . $this->request->base . '/' . Inflector::underscore($plugin)] = APP . 'Plugin/' . $plugin . '/' . WEBROOT_DIR . '/'; } } $_GET['f'] = implode(',', $newFiles); $_GET['symlinks'] = $symLinks; App::import('Vendor', 'Minify.minify/index'); $this->response->statusCode('304'); exit; }
public function __construct($request = null, $response = null) { if (CakePlugin::loaded('DebugKit')) { $this->components[] = 'DebugKit.Toolbar'; } parent::__construct($request, $response); }
protected function _getFullAssetPath($path) { $filepath = preg_replace('/^' . preg_quote($this->Helper->request->webroot, '/') . '/', '', urldecode($path)); $webrootPath = WWW_ROOT . str_replace('/', DS, $filepath); if (file_exists($webrootPath)) { //@codingStandardsIgnoreStart return $webrootPath; //@codingStandardsIgnoreEnd } $segments = explode('/', ltrim($filepath, '/')); if ($segments[0] === 'theme') { $theme = $segments[1]; unset($segments[0], $segments[1]); $themePath = App::themePath($theme) . 'webroot' . DS . implode(DS, $segments); //@codingStandardsIgnoreStart return $themePath; //@codingStandardsIgnoreEnd } else { $plugin = Inflector::camelize($segments[0]); if (CakePlugin::loaded($plugin)) { unset($segments[0]); $pluginPath = CakePlugin::path($plugin) . 'webroot' . DS . implode(DS, $segments); //@codingStandardsIgnoreStart return $pluginPath; //@codingStandardsIgnoreEnd } } return false; }
public function fetch() { $pluginName = '.'; if (isset($this->args['0'])) { $pluginName = $this->args['0']; } $this->out('Installing packages for: ' . $pluginName); $dependencies = array(); if ($pluginName == '.') { // install ALL $dependencies = $this->_getDependencies(APP); foreach (CakePlugin::loaded() as $plugin) { $dependencies = $this->_getDependencies(App::pluginPath($plugin), $dependencies); } } elseif (strtolower($pluginName) == 'app') { // install App only $path = APP; $dependencies = $this->_getDependencies($path); } else { // install Plugin only $path = App::pluginPath($pluginName); $dependencies = $this->_getDependencies($path); } if (count($dependencies) > 0) { $cmd = 'install'; foreach ($dependencies as $name => $semVer) { $cmd .= ' ' . $name . '#' . $semVer; } $this->out($this->_runCmd($cmd)); } else { $this->out('No packages info found to be installed.'); } }
/** * admin_index * * @return void */ public function admin_index() { $acoConditions = array('parent_id !=' => null, 'foreign_key' => null, 'alias !=' => null); $acos = $this->Acl->Aco->generateTreeList($acoConditions, '{n}.Aco.id', '{n}.Aco.alias'); $groups = $this->Group->find('list'); $this->set(compact('acos', 'groups')); $groupsAros = $this->AclAro->find('all', array('conditions' => array('AclAro.model' => 'Group', 'AclAro.foreign_key' => array_keys($groups)))); $groupsAros = Set::combine($groupsAros, '{n}.AclAro.foreign_key', '{n}.AclAro.id'); $permissions = array(); foreach ($acos as $acoId => $acoAlias) { if (substr_count($acoAlias, '_') != 0) { $permission = array(); foreach ($groups as $groupId => $groupTitle) { $hasAny = array('aco_id' => $acoId, 'aro_id' => $groupsAros[$groupId], '_create' => 1, '_read' => 1, '_update' => 1, '_delete' => 1); if ($this->AclPermission->hasAny($hasAny)) { $permission[$groupId] = 1; } else { $permission[$groupId] = 0; } $permissions[$acoId] = $permission; } } } $this->set(compact('groupsAros', 'permissions')); $plugins = CakePlugin::loaded(); $controllers_plugins = array(); if (!empty($plugins)) { foreach ($plugins as $plugin) { $controllers_plugins[] = $this->AclUtility->getControllerList($plugin); } } $controllers = array_merge($this->AclUtility->getControllerList(), $this->AclUtility->getControllerList($plugin)); $this->set(compact('controllers')); }
/** * Builds asset file path based off url * * @param string $url * @return string Absolute path for asset file */ static function getAssetFile($url) { $parts = explode('/', $url); if ($parts[0] === 'theme') { $file = ''; $fileFragments = explode(',', $url); $fileNumber = count($fileFragments); foreach ($fileFragments as $k => $fileFragment) { $fileParts = explode('/', $fileFragment); unset($fileParts[0], $fileParts[1]); if ($fileNumber == $k + 1) { $file .= urldecode(implode(DS, $fileParts)); } else { $file .= urldecode(implode(DS, $fileParts)) . ','; } } $themeName = $parts[1]; $path = Configure::read('App.www_root') . 'theme' . DS . $themeName; if (!file_exists($path)) { $path = App::themePath($themeName) . 'webroot'; } return array($path, $file); } $plugin = Inflector::camelize($parts[0]); if (CakePlugin::loaded($plugin)) { unset($parts[0]); $fileFragment = urldecode(implode(DS, $parts)); $pluginWebroot = CakePlugin::path($plugin) . 'webroot'; return array($pluginWebroot, $fileFragment); } else { return array(WWW_ROOT, $_GET['f']); } }
public function links() { if (!CakePlugin::loaded('Menus')) { CakePlugin::load('Menus'); } App::uses('View', 'View'); App::uses('AppHelper', 'View/Helper'); App::uses('MenusHelper', 'Menus.View/Helper'); $Menus = new MenusHelper(new View()); $Link = ClassRegistry::init('Menus.Link'); $links = $Link->find('all', array('fields' => array('id', 'title', 'link'))); $count = 0; foreach ($links as $link) { if (!strstr($link['Link']['link'], 'controller:')) { continue; } if (strstr($link['Link']['link'], 'plugin:')) { continue; } $url = $Menus->linkStringToArray($link['Link']['link']); if (isset($this->_controllerMap[$url['controller']])) { $url['plugin'] = $this->_controllerMap[$url['controller']]; $linkString = $Menus->urlToLinkString($url); $Link->id = $link['Link']['id']; $this->out(__('Updating Link %s', $Link->id)); $this->warn(__('- %s', $link['Link']['link'])); $this->success(__('+ %s', $linkString), 2); $Link->saveField('link', $linkString, false); $count++; } } $this->out(__('Links updated: %d rows', $count)); }
public function __construct($id = false, $table = null, $ds = null) { if (CakePlugin::loaded('Comments')) { $this->actsAs[] = 'Comments.Commentable'; $this->hasMany['Comment'] = array('className' => 'Comments.Comment', 'foreignKey' => 'foreign_key', 'conditions' => array('Comment.model' => 'UserGroupWallPost')); } parent::__construct($id, $table, $ds); }
public function main() { Configure::write('debug', 2); foreach (CakePlugin::loaded() as $plugin) { $path = App::pluginPath($plugin) . 'Test'; $this->__moveFolders($path); } }
/** * Wrapper for CakePlugin::loaded() * * @throws MissingPluginException * @param string $plugin * @param boolean $exceiption * @return boolean */ protected function _pluginLoaded($plugin, $exception = true) { $result = CakePlugin::loaded($plugin); if ($exception === true && $result === false) { throw new MissingPluginException(array('plugin' => $plugin)); } return $result; }
/** * setUp * * @return void */ public function setUp() { parent::setUp(); $this->Node = ClassRegistry::init('Nodes.Node'); if (!CakePlugin::loaded('Translate')) { CakePlugin::load('Translate'); } $this->Node->Behaviors->attach('Translate.CroogoTranslate', array('fields' => array('title' => 'titleTranslation'))); }
public function __construct($id = false, $table = null, $ds = null) { if (CakePlugin::loaded('Media')) { $this->actsAs[] = 'Media.MediaAttachable'; } if (CakePlugin::loaded('Categories')) { $this->actsAs[] = 'Categories.Categorizable'; } }
/** * Testa se o sluggable behavior está no model * * @return void */ public function testSluggableBehaviorAttached() { $result = CakePlugin::loaded('Utils'); $this->assertTrue($result, 'Utils plugin não está sendo carregado'); $result = $this->Course->actsAs; $expected = 'Utils.Sluggable'; $this->assertInternalType('array', $result, 'Course não tem behaviors'); $this->assertArrayHasKey($expected, $result, 'Course não tem o Sluggable behavior'); }
public function get_all_plugins_paths() { $plugin_names = CakePlugin::loaded(); $plugin_paths = array(); foreach ($plugin_names as $plugin_name) { $plugin_paths[] = CakePlugin::path($plugin_name); } return $plugin_paths; }
/** * _setupAuth * If you have the Users plugin and Auth is not enabled use Users plugin * * @return boolean */ protected function _setupAuth() { if (CakePlugin::loaded('Users') && !$this->Components->enabled('Auth')) { $this->Auth = $this->Components->load('Auth'); $this->Auth->authenticate = array('Form' => array('fields' => array('username' => 'email', 'password' => 'password'), 'userModel' => 'Users.User', 'scope' => array('User.active' => 1))); $this->Auth->loginAction = array('admin' => false, 'plugin' => 'users', 'controller' => 'users', 'action' => 'login'); } return true; }
public function index() { $plugin_names = CakePlugin::loaded(); $plugin_names[] = 'Core'; $db_plugins = $this->Module->find('all'); $existing_plugin = array(); foreach ($db_plugins as $item) { $existing_plugin[] = $item['Module']['name']; } foreach ($plugin_names as $plugin) { if (!in_array($plugin, $existing_plugin)) { $db_plugins[]['Module'] = array('id' => 0, 'name' => $plugin, 'default_owner_bit' => 0, 'default_group_bit' => 0, 'default_public_bit' => 0); } } $render_data = array(); foreach ($db_plugins as $key => $mod) { if ($mod['Module']['id']) { $render_data[$key][] = $mod['Module']['name'] . '<input type="hidden" name="rows[' . $key . '][name]" value="' . $mod['Module']['name'] . '"/><input type="hidden" name="rows[' . $key . '][id]" value="' . $mod['Module']['id'] . '" />'; } else { $render_data[$key][] = $mod['Module']['name'] . '<input type="hidden" name="rows[' . $key . '][name]" value="' . $mod['Module']['name'] . '"/>'; } $render_data[$key][] = '<label class="checkbox ' . $this->_checkBit(OWNER_READ_BIT, $mod['Module']['default_owner_bit']) . '"><input data-toggle="checkbox" name="rows[' . $key . '][default_owner_bit][]" type="checkbox" value="' . OWNER_READ_BIT . '" ' . $this->_checkBit(OWNER_READ_BIT, $mod['Module']['default_owner_bit']) . '/></label>'; $render_data[$key][] = '<label class="checkbox ' . $this->_checkBit(OWNER_WRITE_BIT, $mod['Module']['default_owner_bit']) . '"><input data-toggle="checkbox" name="rows[' . $key . '][default_owner_bit][]" type="checkbox" value="' . OWNER_WRITE_BIT . '" ' . $this->_checkBit(OWNER_WRITE_BIT, $mod['Module']['default_owner_bit']) . '/></label>'; $render_data[$key][] = '<label class="checkbox ' . $this->_checkBit(OWNER_DELETE_BIT, $mod['Module']['default_owner_bit']) . '"><input data-toggle="checkbox" name="rows[' . $key . '][default_owner_bit][]" type="checkbox" value="' . OWNER_DELETE_BIT . '" ' . $this->_checkBit(OWNER_DELETE_BIT, $mod['Module']['default_owner_bit']) . '/></label>'; $render_data[$key][] = '<label class="checkbox ' . $this->_checkBit(GROUP_READ_BIT, $mod['Module']['default_group_bit']) . '"><input data-toggle="checkbox" name="rows[' . $key . '][default_group_bit][]" type="checkbox" value="' . GROUP_READ_BIT . '" ' . $this->_checkBit(GROUP_READ_BIT, $mod['Module']['default_group_bit']) . '/></label>'; $render_data[$key][] = '<label class="checkbox ' . $this->_checkBit(GROUP_WRITE_BIT, $mod['Module']['default_group_bit']) . '"><input data-toggle="checkbox" name="rows[' . $key . '][default_group_bit][]" type="checkbox" value="' . GROUP_WRITE_BIT . '" ' . $this->_checkBit(GROUP_WRITE_BIT, $mod['Module']['default_group_bit']) . '/></label>'; $render_data[$key][] = '<label class="checkbox ' . $this->_checkBit(GROUP_DELETE_BIT, $mod['Module']['default_group_bit']) . '"><input data-toggle="checkbox" name="rows[' . $key . '][default_group_bit][]" type="checkbox" value="' . GROUP_DELETE_BIT . '" ' . $this->_checkBit(GROUP_DELETE_BIT, $mod['Module']['default_group_bit']) . '/></label>'; $render_data[$key][] = '<label class="checkbox ' . $this->_checkBit(OTHER_READ_BIT, $mod['Module']['default_public_bit']) . '"><input data-toggle="checkbox" name="rows[' . $key . '][default_public_bit][]" type="checkbox" value="' . OTHER_READ_BIT . '" ' . $this->_checkBit(OTHER_READ_BIT, $mod['Module']['default_public_bit']) . '/></label>'; $render_data[$key][] = '<label class="checkbox ' . $this->_checkBit(OTHER_WRITE_BIT, $mod['Module']['default_public_bit']) . '"><input data-toggle="checkbox" name="rows[' . $key . '][default_public_bit][]" type="checkbox" value="' . OTHER_WRITE_BIT . '" ' . $this->_checkBit(OTHER_WRITE_BIT, $mod['Module']['default_public_bit']) . '/></label>'; $render_data[$key][] = '<label class="checkbox ' . $this->_checkBit(OTHER_DELETE_BIT, $mod['Module']['default_public_bit']) . '"><input data-toggle="checkbox" name="rows[' . $key . '][default_public_bit][]" type="checkbox" value="' . OTHER_DELETE_BIT . '" ' . $this->_checkBit(OTHER_DELETE_BIT, $mod['Module']['default_public_bit']) . '/></label>'; } if ($this->request->is('post')) { $data = $this->request->data['rows']; foreach ($data as $key => $item) { if (isset($item['default_owner_bit'])) { $data[$key]['default_owner_bit'] = array_sum($item['default_owner_bit']); } else { $data[$key]['default_owner_bit'] = 0; } if (isset($item['default_group_bit'])) { $data[$key]['default_group_bit'] = array_sum($item['default_group_bit']); } else { $data[$key]['default_group_bit'] = 0; } if (isset($item['default_public_bit'])) { $data[$key]['default_public_bit'] = array_sum($item['default_public_bit']); } else { $data[$key]['default_public_bit'] = 0; } } $this->Module->saveMany($data); $this->Session->setFlash(__('All setting has been saved')); return $this->redirect(array('action' => 'index')); } $this->set('data', $render_data); }
public function getPrototypes() { $searchdirs['App'] = APP . 'View'; $searchdirs['Basic'] = CakePlugin::path('Muffin'); foreach (CakePlugin::loaded() as $plugin) { if ($plugin != 'Muffin') { $searchdirs[$plugin] = CakePlugin::path($plugin) . 'View'; } } $configs = array(); foreach ($searchdirs as $plugin => $searchdir) { $dir = new Folder($searchdir, false); if ($files = $dir->findRecursive('config.xml')) { $configs = Hash::merge($configs, array($plugin => $files)); } } $prototypes = array(); foreach ($configs as $plugin => $configFiles) { $i = 0; foreach ($configFiles as $configFile) { $xml = Xml::build($configFile); $items = $xml->xpath('menu/item'); if (!is_array($items) || empty($items)) { continue; } foreach ($items as $item) { $item = Xml::toArray($item); if (empty($item['item']['@label'])) { continue; } if (!isset($item['item']['@id']) || empty($item['item']['@id'])) { $id = ucfirst(Inflector::variable($item['item']['@label'])); } else { $id = $item['item']['@id']; } $fields = array(); foreach ($item['item']['field'] as $key => $field) { foreach ($field as $name => $value) { $name = str_replace('@', '', $name); $fields[$key][$name] = $value; } } $prototypes[$plugin][$i]['Link']['id'] = $id; $prototypes[$plugin][$i]['Link']['priority'] = !empty($item['item']['@priority']) ? $item['item']['@priority'] : '10'; $prototypes[$plugin][$i]['Link']['model'] = !empty($item['item']['@model']) ? $item['item']['@model'] : ''; $prototypes[$plugin][$i]['Link']['label'] = $item['item']['@label']; $prototypes[$plugin][$i]['Field'] = $fields; $i++; } } } foreach ($prototypes as $plugin => $section) { $prototypes[$plugin] = Hash::sort($section, '{n}.Link.priority', 'asc'); } return $prototypes; }
/** * Constructor. * * @param array $config Configuration options. */ public function __construct($config) { parent::__construct($config); if (Configure::read('debug') > 0) { $this->_useLogging = true; } $this->_useDebugKit = CakePlugin::loaded('DebugKit'); $this->loadService(); $this->connect(); }
/** * Url helper function * * - Localize URL. * * @param string $url * @param bool $full * @return mixed * @access public */ public function url($url = null, $full = false) { if (CakePlugin::loaded('I18n')) { $url = Common::url($url); if (is_array($url) && !array_key_exists('lang', $url)) { $url['lang'] = Configure::read('Config.language'); } } return parent::url($url, $full); }