public function actionIndex() { $flickrUsers = FlickrUser::model()->findAll('', array('index' => 'id')); $formManager = new FormManager(array('checkIfPosted' => false, 'redirect' => $this->createUrl('index'), 'forms' => array('id' => 'flickrUsersForm', 'models' => $flickrUsers))); if (isset($_POST['sent'])) { $formManager->process(); } $this->render('index', array('flickrUsers' => $formManager->getModels('flickrUsersForm'))); }
/** @return void */ protected function loadInfo() { $res = FlickrService::$instance->call('flickr.photosets.getInfo', array('photoset_id' => $this->id)); $n =& $res->dom['photoset'][0]; $a =& $n['@']; $this->owner = FlickrUser::findById($a['owner']); $this->primary = FlickrPhoto::findById($a['primary']); $this->secret = $a['secret']; $this->server = $a['server']; $this->photo_count = $a['photos']; $this->title = $n['title'][0]['#']; $this->description = $n['description'][0]['#']; }
/** @return void */ public function loadInfo() { if ($this->has_loaded_info) { return; } $res = FlickrService::$instance->call('flickr.photos.getInfo', array('photo_id' => $this->id)); $n =& $res->dom['photo'][0]; $a =& $n['@']; $this->secret = $a['secret']; $this->server = $a['server']; $this->original_format = $a['originalformat']; $this->title = @$n['title'][0]['#']; $this->description = @$n['description'][0]['#']; $this->owner = FlickrUser::valueOf($n['owner'][0]); if (isset($n['visibility'])) { $this->is_public = intval($n['visibility'][0]['@']['ispublic']); $this->is_friend = intval($n['visibility'][0]['@']['isfriend']); $this->is_family = intval($n['visibility'][0]['@']['isfamily']); } if (isset($n['dates'])) { $this->date_uploaded = intval($n['dates'][0]['@']['posted']); $this->date_taken = strtotime($n['dates'][0]['@']['taken']); $this->date_last_updated = intval($n['dates'][0]['@']['lastupdate']); } foreach ($n['urls'][0]['url'] as $url) { if ($url['@']['type'] == 'photopage') { $this->photopage_url = $url['#']; } } $this->comment_count = intval($n['comments'][0]['#']); /* <photo id="2733" secret="123456" server="12" isfavorite="0" license="3" rotation="90" originalformat="png"> <owner nsid="12037949754@N01" username="******" realname="Cal Henderson" location="Bedford, UK" /> <title>orford_castle_taster</title> <description>hello!</description> <visibility ispublic="1" isfriend="0" isfamily="0" /> <dates posted="1100897479" taken="2004-11-19 12:51:19" takengranularity="0" lastupdate="1093022469" /> <permissions permcomment="3" permaddmeta="2" /> <editability cancomment="1" canaddmeta="1" /> <comments>1</comments> <notes> <note id="313" author="12037949754@N01" authorname="Bees" x="10" y="10" w="50" h="50">foo</note> </notes> <tags> <tag id="1234" author="12037949754@N01" raw="woo yay">wooyay</tag> <tag id="1235" author="12037949754@N01" raw="hoopla">hoopla</tag> </tags> <urls> <url type="photopage">http://www.flickr.com/photos/bees/2733/</url> </urls> </photo> */ $this->has_loaded_info = true; }
<?php echo $this->renderPartial('//adminLayouts/_blocHeader', array('form' => $form, 'model' => $model, 'formId' => $formId, 'itemId' => $itemId)); ?> <?php $userIdsData = CHtml::listData(FlickrUser::model()->findAll(), 'user_id', 'user_id'); $userIds = array(); foreach ($userIdsData as $userId) { $curl = curl_init("https://api.flickr.com/services/rest/?method=flickr.people.getInfo&api_key=cd80122ae0a0f805b279d80715dd7861&user_id=" . urlencode($userId) . "&format=json&nojsoncallback=1"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($curl); curl_close($curl); $mObject = json_decode($data, false); // stdClass object if (isset($mObject->person) && !empty($mObject->person->path_alias)) { $userIds[$userId] = CHtml::encode($mObject->person->path_alias); } else { $userIds[$userId] = $userId; } } ?> <div class="form-group"> <?php echo $form->labelEx($model, '[' . $formId . '][' . $itemId . ']user_id', array('class' => 'control-label col-sm-3 col-xs-12')); ?> <div class="col-sm-6 col-xs-12"><?php echo $form->dropDownList($model, '[' . $formId . '][' . $itemId . ']user_id', $userIds, array('empty' => '', 'class' => 'blocFlickrUserId form-control')); ?> </div>