-
Posts
601 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Frank Vèssia
-
damn, i need to sleep more at night... thanks
-
After updating PW from 2.0 to 2.1 i get a strange behavior in api. I cannot add any image except from the admin. I made more test with no luck, this is my code, very simple. $p = $pages->get(6629); $p->setOutputFormatting(false); $p->immagine->add("http://www.9freepictures.com/d/file/art-online/200907/bob-ross-landscape-oil-painting-27-20.jpg"); $p->save; no warning, no error_log, anything...
-
you are right Adamkiss, putting the sort as last item it works... thanks, it's a bug??
-
@Ryan: yes pdate is date fieldtype. function listVideo($sort="sort=-pdate",$limit=",limit=20",$cats="",$id=""){ $pages= wire('pages'); $today = strtotime(date('d-m-Y')); $videos=$pages->get(1006)->children("$sort$limit$published$cats$id,published=1,pdate<=$today"); foreach($videos as $video){ $new = ""; $vidtime = $video->pdate; $curtime = date("d-m-Y"); $yesterday = date("d-m-Y", strtotime("yesterday")); if ($vidtime==$curtime || $vidtime==$yesterday){ $new = "<div class='newvid'><span class='label success'>Nuovo</span></div>"; } $thumb = $video->videothumb->first()->size(210,118)->url; $totalthumbs = count($video->videothumb); if ($totalthumbs>1){ foreach ($video->videothumb as $tempthumb){ $thumbtemp=$tempthumb->size(210,118)->url; } $vidid = "id='{$video->id}'"; }else{ $vidid = "id=''"; } $videotitle = ucfirst(substr($video->title,0,43)); echo " <div class='blockvideo'> {$new} <div class='videotitleblock'>{$videotitle}</div> <a href='{$video->url}' class='video'> <img class='thumbnail' src='{$thumb}' {$vidid} alt='{$video->title}'> </a> <div class='fake'><img class='fakethumb' src='{$thumb}' ></div> <div class='videostatblock'>Visite: <span class='visits'>{$video->pageviews}</span> | ".strftime("%d %B %Y",strtotime($video->pdate))."<span class='duration'>{$video->duration}</span></div> </div> "; } }
-
i tried, no luck, strange...
-
I have a date field in european format d-m-Y. I want to order my "articles" by this field. I cannot use the created built in field because publisher decide the publish date using this field, but it seems doesn't work using sort=pdate pdate is my date field
-
Where did you find about ProcessWire?
Frank Vèssia replied to apeisa's topic in News & Announcements
Honestly i don't remember but probably i was looking for "custom fields cms" because this WAS the only thing i never found in any other cms. So happy now. ;D -
Module Profile Export module (also upgrade PW 2.0 to 2.1)
Frank Vèssia replied to ryan's topic in Modules/Plugins
it works, one match found. thanks -
Module Profile Export module (also upgrade PW 2.0 to 2.1)
Frank Vèssia replied to ryan's topic in Modules/Plugins
Ryan i got an exception after the upgrade from 2.0 to 2.1, after the admin creation step Exception: Unable to add field '' to Fieldgroup 'annuncio' (in /home/daydule/public_html/wire/core/Fieldgroup.php line 83) This error message was shown because /install.php still exists. Error has been logged. -
I have a PW website with thousand of pages and comments. Any comment must the approved by admin and everytime i need to approve a comment of searching for a comment i loose time searching it. Could be a nice thing having an additional main tab on topbar "Comments" for managing, listing editing ecc...
-
I'm also waiting ;D
-
you can leave the title but at least change the name (url)
-
Voted and reviewed ;D
-
ops..so i really missed something...sorry for bother you. thanks.
-
I created a custom role which can: view, edit and delete pages but when i login with a user with that role i can only view pages... i miss something? I'm using the latest commit.
-
Thanks, it works like a charm ;D
-
I created (or trying to) an inpufieldselect that shows me all files stored in a server folder and save the value as text. It works good but i have two problems. First: I need to execute a function called "sendVideo" after the page is saved based on my select value. I tried to add an hookafter save but the code is executed everytime a page is saved and not only the current page. public function init() { $this->pages->addHookAfter('save', $this, 'sendVideo'); } Second: I need to execute my code only if i change the value of my select and do nothing if not . This is my entire code <?php class FieldtypeSelect extends Fieldtype { public static $defaultOptionValues = array (); public static function getModuleInfo() { return array( 'title' => 'Select temporary videos', 'version' => 100, 'summary' => 'This Fieldtype get files stored in /toencode/ folder', 'singular' => true, 'autoload' => true, ); } public function init() { $this->pages->addHookAfter('save', $this, 'sendVideo'); } public function sendVideo($event) { $page = $event->arguments[0]; $vfile = "http://".$_SERVER['HTTP_HOST']."/videodaconvertire/".$page->videotoconvert; $filename = $page->id; function sendRequestv($xml) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://manage.encoding.com/"); curl_setopt($ch, CURLOPT_POSTFIELDS, "xml=" . urlencode($xml)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); return curl_exec($ch); } // Begin processing User's POST if(!empty($vfile)) { // Preparing XML request // Main fields $req = new SimpleXMLElement('<?xml version="1.0"?><query></query>'); $req->addChild('userid', 'xxxxxx'); $req->addChild('userkey', 'xxxxxxxxxxxxxxxxxxxx'); $req->addChild('action', 'AddMedia'); $req->addChild('source', $vfile); $req->addChild('notify', 'http://www.librolo.com/addmedia/'); $formatNode = $req->addChild('format'); $formatNode->addChild('output', 'flv'); $formatNode->addChild('size', '650x366'); $formatNode->addChild('bitrate', '512k'); $formatNode->addChild('destination','ftp://xxx:xxx@librolo.com/public_html/video/'.$filename.'.flv'); $logoNode = $formatNode->addChild('logo'); $logoNode->addChild('logo_source', 'http://www.librolo.com/watermark.png'); $logoNode->addChild('logo_x', '4'); $logoNode->addChild('logo_y', '4'); $logoNode->addChild('logo_mode', '1'); $formatNode = $req->addChild('format'); $formatNode->addChild('output', 'thumbnail'); $formatNode->addChild('time', '10%'); $formatNode->addChild('width', '650'); $formatNode->addChild('destination', 'ftp://xxx:xxx@librolo.com/public_html/thumbs/'.$filename.'_1.jpg'); $formatNode = $req->addChild('format'); $formatNode->addChild('output', 'thumbnail'); $formatNode->addChild('time', '30%'); $formatNode->addChild('width', '650'); $formatNode->addChild('destination', 'ftp://xxx:xxx@librolo.com/public_html/thumbs/'.$filename.'_2.jpg'); $formatNode = $req->addChild('format'); $formatNode->addChild('output', 'thumbnail'); $formatNode->addChild('time', '50%'); $formatNode->addChild('width', '650'); $formatNode->addChild('destination', 'ftp://xxx:xxx@librolo.com/public_html/thumbs/'.$filename.'_3.jpg'); $formatNode = $req->addChild('format'); $formatNode->addChild('output', 'thumbnail'); $formatNode->addChild('time', '70%'); $formatNode->addChild('width', '650'); $formatNode->addChild('destination', 'ftp://xxx:xxx@librolo.com/public_html/thumbs/'.$filename.'_4.jpg'); $formatNode = $req->addChild('format'); $formatNode->addChild('output', 'thumbnail'); $formatNode->addChild('time', '90%'); $formatNode->addChild('width', '650'); $formatNode->addChild('destination', 'ftp://xxx:xxx@librolo.com/public_html/thumbs/'.$filename.'_5.jpg'); // Sending API request $res = sendRequestv($req->asXML()); try { // Creating new object from response XML $response = new SimpleXMLElement($res); // If there are any errors, set error message if(isset($response->errors[0]->error[0])) { $error = $response->errors[0]->error[0] . ''; } else if ($response->message[0]) { // If message received, set OK message $message =$response->message[0]; } } catch(Exception $e) { // If wrong XML response received $error = $e->getMessage(); } // Displaying error if any if (!empty($error)) { $this->message(htmlspecialchars($error)); } // Displaying message if (!empty($message)) { //$this->message($message); } } } public function getInputfield(Page $page, Field $field) { function read_folder_directory($dir = "root_dir/dir") { $listDir = array(); if($handler = opendir($dir)) { while (($sub = readdir($handler)) !== FALSE) { if ($sub != "." && $sub != ".." && $sub != "Thumb.db" && $sub != "Thumbs.db") { if(is_file($dir."/".$sub)) { $listDir[] = $sub; }elseif(is_dir($dir."/".$sub)){ $listDir[$sub] = ReadFolderDirectory($dir."/".$sub); } } } closedir($handler); } return $listDir; } $inputfield = $this->modules->get('InputfieldSelect'); $inputfield->addOption(''); // blank or unselected option $files = read_folder_directory ($_SERVER["DOCUMENT_ROOT"]."/videodaconvertire/"); if ($files) { foreach ($files as $file) { $inputfield->addOption($file,$file); } } return $inputfield; } public function getDatabaseSchema(Field $field) { $schema = parent::getDatabaseSchema($field); $schema['data'] = 'text NOT NULL'; $schema['keys']['data_exact'] = 'KEY `data_exact` (`data`(255))'; $schema['keys']['data'] = 'FULLTEXT KEY `data` (`data`)'; return $schema; } public function sanitizeValue(Page $page, Field $field, $value) { return $value; } public function ___getConfigInputfields(Field $field) { $inputfields = NULL; return $inputfields; } } This is made for adding a video to a page using encoding.com apis. Basically i upload some videos in a folder, than i create a page and choose a video for encoding, after the page is saved i use encoding.com apis to send request to their server via xml and after the video is encoded and thumbnails created with a callback function that call an hidden pw page i editing the page, add the thumbnails and save it again.
-
thanks
-
I tried, i can delete images from api..but not from admin...
-
Ok, i've added the php validation and imageSizer correctly. Regarding the error in the admin i'm using PW 2.1 latest commit, cannot say more. I'm adding images to user profile in a multi-image field, that's all. It happens for every users, i can see the images both in front end and in the admin but i cannot delete them from the admin, now i will try to delete from api...i will let you know.
-
Your point is correct but i have to say that all my forms have action="" and js call external php pages for making all so nobody can access them...however adding 2 more lines of php for validation code don't cost anything... ;D
-
come on...my website will be not so huge to entering in the target of some hacker or similar, however without js you cannot enter in the website, just the homepage. Try to "use" Facebook without js... I want to deliver the best experience to my users and i decided to use a lot of javascript and css with special features, i also will not support IE6. I don't think the 1% of users with js disabled will affect my activities...i want to focus on a particular target of people.
-
If someone don't have javascript they cannot view the website... and i show up an alert message. I have too many js controls and javascript is essential
-
This is what i've done till now. I'm using jquery validation for image type and size so my php now is more clean. I still need to implement the ImageSizer class because i have some problems with your code but i will explain later. Now i have another problem. $("#profilephotoform").validate({ debug: false, rules: { imageUpload: { required: true, accept: true, filesize: 524288 } }, messages: { imageUpload: "Solo immagini JPG, GIF o PNG di massimo 500 Kb", } }); <? function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } require_once('../index.php'); $input = wire('input'); $sanitizer = wire('sanitizer'); $users = wire('users'); $user = wire('user'); if($_FILES['imageUpload']['name']) { $filename = stripslashes($_FILES['imageUpload']['name']); $extension = getExtension($filename); $image_name=time().$user->id.'.'.$extension; $newname="../site/tmpfiles/profiles/".$image_name; $copied = move_uploaded_file($_FILES['imageUpload']['tmp_name'], $newname); if ($copied) { $user->setOutputFormatting(false); $user->profilephoto->add($config->paths->root."site/tmpfiles/profiles/".$image_name); $user->save(); //delete copied image $tmpfile = $config->paths->root."/site/tmpfiles/profiles/".$image_name; if (file_exists($tmpfile)) { unlink ($tmpfile); } }else{ print "Errore nel salvataggio del file"; exit; } print $user->profilephoto->last()->size(250,0)->url; } ?> The code works good now, i can add images but when i try to delete one of these images from the admin i get this error; Notice: Trying to get property of non-object in /home/librolo/public_html/wire/core/Pagefiles.php on line 207 Fatal error: Call to a member function path() on a non-object in /home/librolo/public_html/wire/core/Pagefiles.php on line 207 P.S.: How can i delete images using api?? Getting back to ImageSizer i tried to implement it but in your code you wrote: $u->profilephoto->add($filename); $filename is the path of the image saved in tmp folder, so i changed to $image that is the new image object created from imageSizer class, but $image return an object and it doesn't work. I printed the $image array and i found $image->filename but also this is not good because is protected, like all properties of $image...