I'm just starting to scratch the surface in yii and am having a heck of a time getting any image slider extensions to work. I've referenced http://www.yiiframework.com/doc/guide/1.1/en/extension.use and believe my problem to be related to the initialization of the extension but am not sure. The most recent extension I'm attempting to use is http://www.yiiframework.com/extension/s3slider/.
So far I've downloaded the extension, unzipped and placed in /protected/extensions. I have two images I'm attempting to slide between located in /images. I've placed the suggested code in my /protected/views/layouts/main.php and updated the $images array as follows:
<?php
$this->widget('application.extensions.s3slider.S3Slider',
array(
'images' => array(
array('images/giveBack.png', 'Give Back'),
array('images/priceGuarantee.png', 'Price Guarantee'),
),
'width' => '420',
'height' => '300',
)
);?>
When I reload my page I get the following error:
PHP notice
Array to string conversion
/protected/extensions/s3slider/S3Slider.php(71)
59 $cssparams = array(
60 'name' => $this->name,
61 'width' => $this->width,
62 'height' => $this->height,
63 'opacity' => $this->opacity,
64 );
65 $clientScript->registerCssFile($baseUrl . '/s3Slider.css.php?data=' . urlencode(base64_encode(serialize($cssparams)))); //http_build_query($cssparams)
66
67 $clientScript->registerCoreScript('jquery');
68
69 $clientScript->registerScriptFile($baseUrl . '/s3Slider.js');
70
71 $js = "jQuery('#{$this->name}').s3Slider($options);";
72 $cs->registerScript('Yii.S3Slider' . $this->name, $js);
73 echo $this->makeImages();
74 }
75
76 }
77 ?>
My stack trace indicates:
/protected/views/layouts/main.php(60): CBaseController->widget("application.extensions.s3slider.S3Slider", array("images" => array(array("images/giveBack.png", "Give Back"), array("images/priceGuarantee.png", "Price Guarantee")), "width" => "420", "height" => "300"))
55 array('images/priceGuarantee.png', 'Price Guarantee'),
56 ),
57 'width' => '420',
58 'height' => '300',
59 )
60 );?>
61
62 <?php
63 $this->widget('zii.widgets.CBreadcrumbs', array(
64 'links'=>$this->breadcrumbs,
65 )); ?><!-- breadcrumbs -->
Any guidance on this would be much appreciated!
Thank you.
You successfully installed this extension, however there is a obvious bug in it.
Note, that at line 52 $options is declared
$options = array();
Then it is checked if not empty:
if (!empty($options)) {
$options = CJavaScript::encode($options);
}
So $options is empty, so it is not encoded to string with encode, so in:
$js = "jQuery('#{$this->name}').s3Slider($options);";
PHP shows notice about array to string conversion. Remove condition for checking if empty, and it will encode empty array and should work. Author of extension probably has notices disabled, which is bad practice. It is wise to see notices at development stage.
HINT: When you get better in yii, writing extension wrapper for jquery plugins will be snap for you.
Related
I have installed OroCommerce, a Symfony2 based application. I want to have the 'vendor' directory on a higher level outside the users directory. I followed the steps at http://symfony.com/doc/current/configuration/override_dir_structure.html#override-the-vendor-directory but now the namespaces can't be found. I get the following error:
InvalidArgumentException in YamlFileLoader.php line 399: There is no extension able to load the configuration for "framework" (in /home/oro2/public_html/app/config/config_dev.yml). Looked for namespace "framework", found "web_profiler", "sensio_distribution", "debug"
in YamlFileLoader.php line 399
at YamlFileLoader->validate(array('imports' => array(array('resource' => 'config.yml')), 'framework' => array('router' => array('resource' => '%kernel.root_dir%/config/routing_dev.yml'), 'profiler' => array('only_exceptions' => false)), 'web_profiler' => array('toolbar' => true, 'intercept_redirects' => false), 'monolog' => array('handlers' => array('main' => array('type' => 'stream', 'path' => '%kernel.logs_dir%/%kernel.environment%.log', 'level' => 'debug'))), 'oro_assetic' => array('css_debug' => null, 'css_debug_all' => false), 'oro_message_queue' => array('client' => array('traceable_producer' => true))), '/home/oro2/public_html/app/config/config_dev.yml') in YamlFileLoader.php line 369
at YamlFileLoader->loadFile('/home/oro2/public_html/app/config/config_dev.yml') in YamlFileLoader.php line 44
at YamlFileLoader->load('/home/oro2/public_html/app/config/config_dev.yml', null) in DelegatingLoader.php line 45
at DelegatingLoader->load('/home/oro2/public_html/app/config/config_dev.yml') in AppKernel.php line 35
at AppKernel->registerContainerConfiguration(object(DelegatingLoader)) in bootstrap.php.cache line 2776
at Kernel->buildContainer() in bootstrap.php.cache line 2728
at Kernel->initializeContainer() in OroKernel.php line 290
at OroKernel->initializeContainer() in bootstrap.php.cache line 2507
at Kernel->boot() in OroKernel.php line 252
at OroKernel->boot() in bootstrap.php.cache line 2538
at Kernel->handle(object(Request)) in app_dev.php line 33
Am I forgetting something? Does anyone know how to solve this problem?
You are somewhere calling %kernel.root_dir%/config/routing_dev.yml which actually does not exist, because you have moved the config file dir
How to get the whatsapp password using the whatsapp api?
I am still learning on using the api and have no idea to use it. I'am using sublime code editor for the code. Below is the sample code that I receive from one of the tutorials.
require_once('Chat-API/src/Registration.php');
username = "6012xxxxxxx";
$debug = true;
// Create a instance of Registration class.
$r = new Registration($username, $debug);
$r->codeRequest('sms'); // could be 'voice' too`
When I execute it, I receive this error:
Array ( [cc] => 60 [in] => 6012xxxxxxx [lg] => en [lc] => MY [id] => 蜀��|#b�պ�`���x [token] => IAW+aljx1hbtx0Vh/sqxJmKytyc= [mistyped] => 6 [network_radio_type] => 1 [simnum] => 1 [s] => [copiedrc] => 1 [hasinrc] => 1 [rcmatch] => 1 [pid] => 5138 [rchash] => 6557f1fa8776a69cc3427a6196467690cb85cc651b36cc7be02062470a72a742 [anhash] => 3c24581d24189c24a487cae2ef84d1c3 [extexist] => 1 [extstate] => 1 [mcc] => 502 [mnc] => 000 [sim_mcc] => 502 [sim_mnc] => 000 [method] => sms ) stdClass Object ( [login] => 6012xxxxxxx [status] => fail [reason] => old_version )
Fatal error: Uncaught exception 'Exception' with message 'There was a problem trying to request the code.' in C:\xampp\htdocs\tutorial\whatsapp-api\Chat-API\src\Registration.php:316 Stack trace: #0 C:\xampp\htdocs\tutorial\whatsapp-api\requestCode.php(33): Registration->codeRequest('sms') #1 {main} thrown in C:\xampp\htdocs\tutorial\whatsapp-api\Chat-API\src\Registration.php on line 316
I tried to use Wart application as well but still unable to get the password with the error of bad_token
Is there any other functions or application that I need to add. Is there also a good tutorial or video for this?
I also tried this lib, but got "fail [reason] => old_version". This library is unsupported since 10 Aug 2016. So I think it won't be working.
Try this one :
in src/Constants.php on line 22, change into
const WHATSAPP_VER = '2.17.242';
in src/Constants.php on line 27, change into
const WHATSAPP_USER_AGENT = 'WhatsApp/2.17.242 Android/4.3 Device/Xiaomi-HM_1SW';
in src/token.php on line 10, change into
$classesMd5 = 'ziYneeSZm5qExsEFX/AoMQ=='; // 2.17.242
Hope this helps.
https://github.com/tgalal/yowsup/issues/1905
I have changed the value of the constant variables in the file
src/Constants.php :
const WHATSAPP_VER = '2.18.371';
const WHATSAPP_USER_AGENT = 'WhatsApp/2.18.371 Android/4.3 Device/Xiaomi-HM_1SW';
and in the file src/token.php
$classesMd5 = 'sdGH+cA0CQfRGvQVnhZWDw==';
After that, I don't get an old_version message.
Try this one:
Open: https://coderus.openrepos.net/whitesoft/whatsapp_scratch.
Note property a and d from those json. When I write this answer, the values are>> a: 5eItLCbGXx3CKpybxo81/A== and d: 2.19.15
_MD5_CLASSES = "5eItLCbGXx3CKpybxo81/A=="
_VERSION = "2.19.15"
im working in SmFony Project but i got some issues when i would get access on my poject via this URL : http://localhost/oksa-depannage/web/app_dev.php/login
"OKSA-DEPANNAGE" is a project name.
So i hope that my question is clear
Errors :
in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 106
at ParameterBag->get('java_path') in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 232
at ParameterBag->resolveString('%java_path%', array()) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 203
at ParameterBag->resolveValue('%java_path%', array()) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 193
at ParameterBag->resolveValue(array('debug' => '%kernel.debug%', 'use_controller' => false, 'bundles' => array('OksaTemplateBundle'), 'java' => '%java_path%', 'filters' => array('cssrewrite' => null, 'yui_css' => array('jar' => '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'), 'yui_js' => array('jar' => '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'))), array()) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag.php line 193
at ParameterBag->resolveValue(array(array('debug' => '%kernel.debug%', 'use_controller' => false, 'bundles' => array('OksaTemplateBundle'), 'java' => '%java_path%', 'filters' => array('cssrewrite' => null, 'yui_css' => array('jar' => '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'), 'yui_js' => array('jar' => '%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar'))), array('use_controller' => true))) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass.php line 44
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass.php line 39
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\Compiler\Compiler.php line 117
at Compiler->compile(object(ContainerBuilder)) in C:\wamp\www\oksa-depannage\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\ContainerBuilder.php line 619
at ContainerBuilder->compile() in C:\wamp\www\oksa-depannage\app\bootstrap.php.cache line 2491
at Kernel->initializeContainer() in C:\wamp\www\oksa-depannage\app\bootstrap.php.cache line 2270
at Kernel->boot() in C:\wamp\www\oksa-depannage\app\bootstrap.php.cache line 2301
at Kernel->handle(object(Request)) in C:\wamp\www\oksa-depannage\web\app_dev.php line 28
thanks for your helps.
Looks like symfony is trying to start the yui compressor, which is a java library.
This post has a workaround to make this situation work on windows: symfony2 assetics yui compressor on windows (path syntax)
When am adding an extension (EfontAwesome, ref: www.yiiframework.com/extension/efontawesome) to Yii I am getting "chmod(): operation not permitted"
The Call Stack looked something like this..
/opt/lampp/htdocs/yii-1.1.13/framework/utils/CFileHelper.php(133)
121 while(($file=readdir($folder))!==false)
122 {
123 if($file==='.' || $file==='..')
124 continue;
125 $path=$src.DIRECTORY_SEPARATOR.$file;
126 $isFile=is_file($path);
127 if(self::validatePath($base,$file,$isFile,$fileTypes,$exclude))
128 {
129 if($isFile)
130 {
131 copy($path,$dst.DIRECTORY_SEPARATOR.$file);
132 if(isset($options['newFileMode']))
133 chmod($dst.DIRECTORY_SEPARATOR.$file,$options['newFileMode']);
134 }
135 elseif($level)
136 self::copyDirectoryRecursive($path,$dst.DIRECTORY_SEPARATOR.$file,$base.'/'.$file,$fileTypes,$exclude,$level-1,$options);
137 }
138 }
139 closedir($folder);
140 }
141
142 /**
143 * Returns the files found under the specified directory and subdirectories.
144 * This method is mainly used by {#link findFiles}.
145 * #param string $dir the source directory
Stack Trace
#0
+ /opt/lampp/htdocs/yii-1.1.13/framework/utils/CFileHelper.php(133): chmod("/opt/lampp/htdocs/im/assets/6950b6ca/css/font-awesome.css", 438)
#1
+ /opt/lampp/htdocs/yii-1.1.13/framework/utils/CFileHelper.php(136): CFileHelper::copyDirectoryRecursive("/opt/lampp/htdocs/im/protected/extensions/EFontAwesome/assets/cs...", "/opt/lampp/htdocs/im/assets/6950b6ca/css", "/css", array(), ...)
#2
+ /opt/lampp/htdocs/yii-1.1.13/framework/utils/CFileHelper.php(63): CFileHelper::copyDirectoryRecursive("/opt/lampp/htdocs/im/protected/extensions/EFontAwesome/assets", "/opt/lampp/htdocs/im/assets/6950b6ca", "", array(), ...)
#3
+ /opt/lampp/htdocs/yii-1.1.13/framework/web/CAssetManager.php(251): CFileHelper::copyDirectory("/opt/lampp/htdocs/im/protected/extensions/EFontAwesome/assets", "/opt/lampp/htdocs/im/assets/6950b6ca", array("exclude" => array(".svn", ".gitignore"), "level" => -1, "newDirMode" => 511, "newFileMode" => 438))
#4
– /opt/lampp/htdocs/im/protected/extensions/EFontAwesome/components/EFontAwesome.php(41): CAssetManager->publish("/opt/lampp/htdocs/im/protected/extensions/EFontAwesome/assets", false, -1, true)
36 public function getAssetsUrl() {
37 if (isset($this->_assetsUrl))
38 return $this->_assetsUrl;
39 else {
40 $assetsPath = Yii::getPathOfAlias('efontawesome.assets');
41 $assetsUrl = Yii::app()->assetManager->publish($assetsPath, false, -1, YII_DEBUG);
42 return $this->_assetsUrl = $assetsUrl;
43 }
44 }
45 }
This is only happening in debug mode and not in production mode.
The directory is writable by the web process (as it can be seen to work in production mode) and this extension was working perfectly well in debug mode few days back,
A brief google search only bought up the this closed issue on github :https://github.com/yiisoft/yii/issues/1853 regarding forcedCopy and linkAssets config conflict, which was fixed in Yii-1.1.13(the version I am using), just to be safe I had also tried setting the config of both to false in the main config files like this
'assetManager' => array(
'linkAssets' => false,
'forceCopy'=>false,
),
but the issue is persisting, any ideas on how to solve this?
I'm new to cakephp and following this tutorial for a user authentication system
http://bakery.cakephp.org/articles/SeanCallan/2007/04/17/simple-form-authentication-in-1-2-x-x
The only thing I changed is in the file login.ctp. I changed the pointers from
$form->
to
$this->Form->
I'm getting two errors and I can't figure out why. Here is the first
Warning (2): Illegal offset type [CORE\Cake\Model\Model.php, line 2603]
This is the code/context it displays
if ($type !== 'all') {
if ($this->findMethods[$type] === true) {
$type = array(
'username' => '',
'password' => '*****'
)
$query = array(
'conditions' => null,
'fields' => null,
'joins' => array(),
'limit' => null,
'offset' => null,
'order' => null,
'page' => (int) 1,
'group' => null,
'callbacks' => true,
(int) 0 => 'id',
(int) 1 => 'username'
)
$this = object(User) {}
This information was also displayed
Model::buildQuery() - CORE\Cake\Model\Model.php, line 2603
Model::find() - CORE\Cake\Model\Model.php, line 2562
User::validateLogin() - APP\Model\User.php, line 9
UsersController::login() - APP\Controller\UsersController.php, line 21
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE\Cake\Controller\Controller.php, line 484
Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 104
Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 86
[main] - APP\webroot\index.php, line 96
Here is the second error
Warning (2): Illegal offset type [CORE\Cake\Model\Model.php, line 2579]
This is the code it displays
return $results;
} else {
if ($this->findMethods[$type] === true) {
$type = array(
'username' => '',
'password' => '*****'
)
$query = array(
'conditions' => null,
'fields' => null,
'joins' => array(),
'limit' => null,
'offset' => null,
'order' => array(
),
'page' => (int) 1,
'group' => null,
'callbacks' => true,
(int) 0 => 'id',
(int) 1 => 'username'
)
$results = array(
(int) 0 => array(
)
)
$this = object(User) {}
Here is the additional information
Model::find() - CORE\Cake\Model\Model.php, line 2579
User::validateLogin() - APP\Model\User.php, line 9
UsersController::login() - APP\Controller\UsersController.php, line 21
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE\Cake\Controller\Controller.php, line 484
Dispatcher::_invoke() - CORE\Cake\Routing\Dispatcher.php, line 104
Dispatcher::dispatch() - CORE\Cake\Routing\Dispatcher.php, line 86
[main] - APP\webroot\index.php, line 96
I would suggest you follow the more recent tutorial at
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html
Which should follow your setup exactly since you are using cakephp 2.1. The one you are trying to follow now is for cakephp1.2 and was written on 2007 so I doubt it's going to be useful for you.