Picture pinnit

This is the code:

//PicturePost.php

<?php

class WPicturePost extends UFormWorklet{

public &#036;modelClassName = 'MPictureForm';


public &#036;post;


public function accessRules(){


	return array(


	array('deny', 'users'=&gt;array('?'))


	);


}


public function afterModel(){


if(&#036;this-&gt;isPopup()){


	if(isset(&#036;_GET['image']))


	&#036;this-&gt;model-&gt;imageUrl = &#036;_GET['image'];


	if(isset(&#036;_GET['source']))


		&#036;this-&gt;model-&gt;source = &#036;_GET['source'];


		app()-&gt;controller-&gt;layout = 'popup';


	}


}


public function taskIsPopup(){


	return app()-&gt;controller-&gt;routeEased == 'picture/post' &amp;&amp; (&#33;isset(&#036;_POST['isPopup']) || &#036;_POST['isPopup']);


}


public function properties(){


	return array(


		'action' =&gt; url('/picture/post'),


		'elements' =&gt; array(


			CHtml::hiddenField('isPopup', &#036;this-&gt;isPopup()),


			'parentId' =&gt; array('type' =&gt; 'hidden'),


			'imageUrl' =&gt; array('type' =&gt; 'hidden'),


			'source' =&gt; array('type' =&gt; 'hidden'),


			'boardId' =&gt; array('type' =&gt; 'dropdownlist', 'items' =&gt; wm()-&gt;get('picture.helper')-&gt;boards()),


			'message' =&gt; array('type' =&gt; 'textarea', 'layout' =&gt; &quot;&lt;div class=&#092;&quot;clearfix&#092;&quot;&gt;{label}&lt;/div&gt;{input}&#092;n{hint}&quot;),


		),


		'buttons' =&gt; array(


			'submit' =&gt; array('type' =&gt; 'submit',


				'label' =&gt; &#036;this-&gt;t('{#post_v_ucf} It'))


		),


		'model' =&gt; &#036;this-&gt;model


	);


}


public function beforeRenderOutput(){


	cs()-&gt;registerScriptFile(asma()-&gt;publish(&#036;this-&gt;module-&gt;basePath.DS.'js'.DS.'simpleSlide'.DS.'jquery.simpleSlide.js'));


}


public function taskSettings(){


	return array(


		'noImagesFound' =&gt; str_replace('&quot;','&#092;&quot;',&#036;this-&gt;t('Unfortunately we were not able to find any big images.')),


		'minWidth' =&gt; &#036;this-&gt;param('minWidth'),


	);


}


public function afterRenderOutput(){


	&#036;settings = CJavaScript::encode(&#036;this-&gt;settings());


	cs()-&gt;registerScript(__CLASS__,'&#036;.uniprogy.picture.post.init('.&#036;settings.');');


	if(&#036;this-&gt;isPopup()){


		&#036;images = CJavaScript::jsonEncode(array(&#036;this-&gt;model-&gt;imageUrl));


		cs()-&gt;registerScript('&#036;.uniprogy.picture.post.load',


			'&#036;.uniprogy.picture.post.load('. &#036;images.',&quot;'.CJavaScript::quote(&#036;this-&gt;model-&gt;source).'&quot;)');


	}


}


public function taskSave(){


	&#036;helper = wm()-&gt;get('picture.helper');


	&#036;channel = '';


	&#036;picture = null;


	if(&#036;this-&gt;model-&gt;parentId){


		&#036;parent = MPicturePost::model()-&gt;findByPk(&#036;this-&gt;model-&gt;parentId);


		&#036;this-&gt;post = &#036;helper-&gt;repost(&#036;parent, &#036;this-&gt;model-&gt;boardId, &#036;this-&gt;model-&gt;message);


		wm()-&gt;get('picture.event')-&gt;repost(&#036;parent-&gt;id,&#036;this-&gt;post-&gt;id);			


		wm()-&gt;get('picture.helper')-&gt;updateStats(&#036;this-&gt;model-&gt;parentId, 'reposts');


		&#036;this-&gt;successUrl = url('/picture/view', array('id' =&gt; &#036;this-&gt;post-&gt;id));


		return true;


	}


	elseif(is_numeric(&#036;this-&gt;model-&gt;source)){


		&#036;bin = app()-&gt;storage-&gt;bin(&#036;this-&gt;model-&gt;source);


		if(&#036;bin){


			&#036;picture = &#036;helper-&gt;savePicture(&#036;bin-&gt;getFilePath('original'), &#036;bin);


			&#036;channel = 'upload';


			&#036;this-&gt;model-&gt;source = null;


		}


	}


	elseif(&#036;this-&gt;model-&gt;imageUrl){


		&#036;file = &#036;helper-&gt;saveInStorage(&#036;this-&gt;model-&gt;imageUrl);


		if(&#036;file){


			&#036;picture = &#036;helper-&gt;savePicture(&#036;file);


			&#036;channel = 'web';


		}


	}


	if(&#036;picture){


		&#036;this-&gt;post = &#036;helper-&gt;post(&#036;picture-&gt;id, &#036;this-&gt;model-&gt;boardId, &#036;this-&gt;model-&gt;message, &#036;channel, &#036;this-&gt;model-&gt;source);


		wm()-&gt;get('picture.event')-&gt;post(&#036;this-&gt;post-&gt;id);


		&#036;this-&gt;successUrl = url('/picture/view', array('id' =&gt; &#036;this-&gt;post-&gt;id));


		return true;


	}


	&#036;this-&gt;model-&gt;addError('boardId', &#036;this-&gt;t('Unknown error occured. Please try again later.'));


}





public function ajaxSuccess(){


	if(&#036;this-&gt;isPopup()){


		&#036;content = &#036;this-&gt;render('thankYou',array(),true);


		wm()-&gt;get('base.init')-&gt;addToJson(array(


			'content' =&gt; array('replace' =&gt; &#036;content


				.CHtml::script('jQuery(&quot;#closeButton&quot;).click(function(){window.close();});')


				.CHtml::script('jQuery(&quot;#viewButton&quot;).click(function(){window.open(&quot;'.aUrl('/picture/view', array('id' =&gt; &#036;this-&gt;post-&gt;id)).'&quot;);});')


			),


		));


	}


	else


		parent::ajaxSuccess();


}

}

//End of code

//post.php

<div class=‘clearfix append-bottom’>

&lt;div class='column'&gt;&lt;?php


	&#036;this-&gt;render('avatar', array('model' =&gt; &#036;post-&gt;user));


?&gt;&lt;/div&gt;


&lt;div class='column last'&gt;


	&lt;h2&gt;&lt;?php


		echo &#036;post-&gt;user-&gt;firstName.' '.&#036;post-&gt;user-&gt;lastName;


	?&gt;&lt;/h2&gt;&lt;div class='channelInfo'&gt;&lt;?php


	echo wm()-&gt;get('picture.helper')-&gt;channel(&#036;post);


	?&gt;&lt;/div&gt;


&lt;/div&gt;

</div>

<hr />

<div class=‘pictureButtons’><?php

app()-&gt;controller-&gt;worklet('picture.buttons', array('post' =&gt; &#036;post));

?></div>

<div class=‘pictureImage’><?php

echo &#036;this-&gt;content();

?></div>

<div><?php echo $post->message; ?></div>

//End of code

every thing seems to be functioning correctly, but when i submit, it returns ‘Unknown error occurred. Please try again later.’

Please see the attached images for better understanding of the problem.

I am new to YII, could any one explain it to me, how this logic actually works and how to debug these scripts.

I use wamp server & xampp also i have my live testing server…

Also, its available on GIT

Thanks in advance,

Tahmid

did you get any solution