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')); }
/** * アバター自動生成処理 * * @param Model $model ビヘイビア呼び出し元モデル * @param array $user ユーザデータ配列 * @return mixed On success Model::$data, false on failure * @throws InternalErrorException */ public function createAvatarAutomatically(Model $model, $user) { //imagickdraw オブジェクトを作成します $draw = new ImagickDraw(); //文字色のセット $draw->setfillcolor('white'); //フォントサイズを 160 に設定します $draw->setFontSize(140); //テキストを追加します $draw->setFont(CakePlugin::path($model->plugin) . 'webroot' . DS . 'fonts' . DS . 'ipaexg.ttf'); $draw->annotation(19, 143, mb_substr(mb_convert_kana($user['User']['handlename'], 'KVA'), 0, 1)); //新しいキャンバスオブジェクトを作成する $canvas = new Imagick(); //ランダムで背景色を指定する $red1 = strtolower(dechex(mt_rand(3, 12))); $red2 = strtolower(dechex(mt_rand(0, 15))); $green1 = strtolower(dechex(mt_rand(3, 12))); $green2 = strtolower(dechex(mt_rand(0, 15))); $blue1 = strtolower(dechex(mt_rand(3, 12))); $blue2 = strtolower(dechex(mt_rand(0, 15))); $canvas->newImage(179, 179, '#' . $red1 . $red2 . $green1 . $green2 . $blue1 . $blue2); //ImagickDraw をキャンバス上に描画します $canvas->drawImage($draw); //フォーマットを PNG に設定します $canvas->setImageFormat('png'); App::uses('TemporaryFolder', 'Files.Utility'); $folder = new TemporaryFolder(); $filePath = $folder->path . DS . Security::hash($user['User']['handlename'], 'md5') . '.png'; $canvas->writeImages($filePath, true); return $filePath; }
/** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); Cache::delete('object_map', '_cake_core_'); App::build(); CakePlugin::unload(); }
/** * setUp * * @return void */ public function setUp() { parent::setUp(); App::build(array('View' => array(CakePlugin::path('Taxonomy') . 'View' . DS)), App::APPEND); $this->VocabulariesController = $this->generate('Taxonomy.Vocabularies', array('methods' => array('redirect'), 'components' => array('Auth' => array('user'), 'Session'))); $this->VocabulariesController->Auth->staticExpects($this->any())->method('user')->will($this->returnCallback(array($this, 'authUserCallback'))); }
/** * All test suite * * @return CakeTestSuite */ public static function suite() { $plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__); $suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin)); $suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case'); return $suite; }
public function setUp() { $this->FileManager = new FileManager(false, null, null, null); $this->__testAppPath = CakePlugin::path('FileManager') . 'Test' . DS . 'test_app' . DS; $this->__setFilePathsForTests(); parent::setUp(); }
/** * 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(); }
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)); }
/** * AppController::constructClasses() * * @return void */ public function constructClasses() { if (CakePlugin::loaded('DebugKit')) { $this->components[] = 'DebugKit.Toolbar'; } parent::constructClasses(); }
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(); }
public function setUp() { parent::setUp(); App::build(array('Plugin' => array(CakePlugin::path('Extensions') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), App::PREPEND); $this->CroogoPlugin = new CroogoPlugin(); $this->_mapping = array(1346748762 => array('version' => 1346748762, 'name' => '1346748762_first', 'class' => 'First', 'type' => 'app', 'migrated' => '2012-09-04 10:52:42'), 1346748933 => array('version' => 1346748933, 'name' => '1346748933_addstatus', 'class' => 'AddStatus', 'type' => 'app', 'migrated' => '2012-09-04 10:55:33')); }
public function testThemeAndPluginInclusion() { App::build(array('Plugin' => array($this->_testFiles . 'Plugin' . DS), 'View' => array($this->_testFiles . 'View' . DS))); CakePlugin::load('TestAsset'); $settings = array('paths' => array(), 'theme' => 'Red'); $this->filter->settings($settings); $this->_themeDir = $this->_testFiles . DS . 'View' . DS . 'Themed' . DS . $settings['theme'] . DS; $content = file_get_contents($this->_themeDir . 'webroot' . DS . 'theme.js'); $result = $this->filter->input('theme.js', $content); $expected = <<<TEXT var Theme = new Class({ }); var ThemeInclude = new Class({ }); var Plugin = new Class({ }); TEXT; $this->assertTextEquals($expected, $result); }
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; }
/** * @param array $scripts to minify * @param array $options theme */ public function css($scripts, $options = array()) { if (Configure::read('debug') || Configure::read('Minify.minify') === false) { return $this->Html->css($scripts); } $options = Set::merge(array('theme' => $this->_View->theme, 'plugin' => false, 'subdir' => false), $options); extract($options); $path = APP; if (!empty($theme)) { $path = App::themePath($theme); } elseif (!empty($plugin)) { $path = CakePlugin::pluginPath($plugin); } $targetDirectory = $path . DS . 'webroot' . DS . 'css' . DS; $outputfile = $targetDirectory . $subdir . DS . 'minified-' . sha1(join(':', $scripts)) . '.css'; if (file_exists($outputfile)) { $outputfile = str_replace($targetDirectory, '', $outputfile); return $this->Html->css($outputfile); } $contents = ''; foreach ($scripts as $script) { $file = $targetDirectory . $script; if (!preg_match('/\\.css$/', $file)) { $file .= '.css'; } $contents .= file_get_contents($file); } $contents = Minify_CSS_Compressor::process($contents); file_put_contents($outputfile, $contents); return $this->Html->css($scripts); }
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.'); } }
protected function _configTestFile($path = null, $baseKey = null) { if ($path === null) { $path = CakePlugin::path('YamlReader') . 'Test' . DS . 'files' . DS; } Configure::config('YamlTestConfig', new YamlReader($path, $baseKey)); }
public function testParsePlural() { $path = CakePlugin::path('Translations') . 'Test/Files/plural.po'; $result = PoParser::parse($path); $expected = array('count' => 3, 'translations' => array(array('locale' => 'en', 'domain' => 'plural', 'category' => 'LC_MESSAGES', 'key' => '%d post', 'value' => '1 post'), array('locale' => 'en', 'domain' => 'plural', 'category' => 'LC_MESSAGES', 'key' => '%d posts', 'value' => '1 post', 'single_key' => '%d post', 'plural_case' => 0), array('locale' => 'en', 'domain' => 'plural', 'category' => 'LC_MESSAGES', 'key' => '%d posts', 'value' => '%d many posts', 'single_key' => '%d post', 'plural_case' => 1)), 'settings' => array('domain' => 'plural')); $this->assertSame($expected, $result); }
/** * 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)); }
/** * Suite define the tests for this suite * * @return void */ public static function suite() { $suite = new PHPUnit_Framework_TestSuite('All Oauth Plugin Tests'); $basePath = CakePlugin::path('OauthLib') . 'Test' . DS . 'Case' . DS; $libs = $basePath . 'Lib' . DS; $tokens = $libs . 'Token' . DS; $spec = $basePath . 'Spec' . DS; // Libs $suite->addTestFile($libs . 'ClientHttpGoogleTest.php'); $suite->addTestFile($libs . 'ClientHttpTermieTest.php'); $suite->addTestFile($libs . 'ClientHttpTest.php'); $suite->addTestFile($libs . 'ConsumerGoogleTest.php'); $suite->addTestFile($libs . 'ConsumerTest.php'); $suite->addTestFile($libs . 'HmacTest.php'); $suite->addTestFile($libs . 'RequestFactoryTest.php'); $suite->addTestFile($libs . 'SignatureTest.php'); // Libs/Token $suite->addTestFile($tokens . 'AccessTokenTest.php'); $suite->addTestFile($tokens . 'RequestTokenTest.php'); $suite->addTestFile($tokens . 'TokenTest.php'); // Libs/RequestProxy $suite->addTestFile($libs . 'RequestProxy' . DS . 'RequestProxyControllerTest.php'); $suite->addTestFile($libs . 'RequestProxy' . DS . 'RequestProxyHttpTest.php'); // Spec $suite->addTestFile($spec . 'ConstructRequestUrlTest.php'); $suite->addTestFile($spec . 'NormalizeRequestParametersTest.php'); $suite->addTestFile($spec . 'SignatureBaseStringsTest.php'); return $suite; }
/** * 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(); }
/** * 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']); } }
/** * 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; }
/** * 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; }
/** * Suite define the tests for this suite * * @return void */ public static function suite() { $suite = new CakeTestSuite('All Bs3Helpers tests'); $path = CakePlugin::path('Bs3Helpers') . 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' . DS; $suite->addTestDirectory($path); return $suite; }
public function setUp() { $this->_paths = App::paths(); $app = CakePlugin::path('Menus') . 'Test' . DS . 'test_app' . DS; App::build(array('Controller' => array($app . 'Controller' . DS), 'View' => array($app . 'View' . DS))); $this->generate('MenusTest'); }
/** * HtmlExtHelperTest::testImageFromBlob() * * @return void */ public function testImageFromBlob() { $folder = CakePlugin::path('Tools') . 'Test' . DS . 'test_files' . DS . 'img' . DS; $content = file_get_contents($folder . 'hotel.png'); $is = $this->Html->imageFromBlob($content); $this->assertTrue(!empty($is)); }
public static function suite() { $suite = new CakeTestSuite('OAuth Tests'); $path = CakePlugin::path('OAuth') . 'Test' . DS . 'Case' . DS; $suite->addTestDirectory($path . 'Model' . DS . 'Behavior'); return $suite; }
/** * Suite define the tests for this suite * * @return void */ public static function suite() { $suite = new CakeTestSuite('All Users tests'); $path = CakePlugin::path('Users') . 'Test' . DS . 'Case' . DS; $suite->addTestDirectoryRecursive($path); return $suite; }
/** * Suite define the tests for this suite * * @return void */ public static function suite() { $Suite = new CakeTestSuite('All Comments Plugin tests'); $basePath = CakePlugin::path('TinyMCE') . DS . 'Test' . DS . 'Case' . DS; $Suite->addTestDirectory($basePath . DS . 'View' . DS . 'Helper'); return $Suite; }