本文整理汇总了PHP中CakePlugin类的典型用法代码示例。如果您正苦于以下问题:PHP CakePlugin类的具体用法?PHP CakePlugin怎么用?PHP CakePlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CakePlugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_index
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'));
}
示例2: createAvatarAutomatically
/**
* アバター自動生成処理
*
* @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;
}
示例3: tearDown
/**
* tearDown method
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
Cache::delete('object_map', '_cake_core_');
App::build();
CakePlugin::unload();
}
示例4: setUp
/**
* 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')));
}
示例5: suite
/**
* 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;
}
示例6: setUp
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();
}
示例7: __construct
/**
* 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();
}
示例8: links
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));
}
示例9: constructClasses
/**
* AppController::constructClasses()
*
* @return void
*/
public function constructClasses()
{
if (CakePlugin::loaded('DebugKit')) {
$this->components[] = 'DebugKit.Toolbar';
}
parent::constructClasses();
}
示例10: main
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();
}
示例11: setUp
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'));
}
示例12: testThemeAndPluginInclusion
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);
}
示例13: __construct
public function __construct($request = null, $response = null)
{
if (CakePlugin::loaded('DebugKit')) {
$this->components[] = 'DebugKit.Toolbar';
}
parent::__construct($request, $response);
}
示例14: _getFullAssetPath
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;
}
示例15: css
/**
* @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);
}