Jump to content

horst

PW-Moderators
  • Posts

    4,085
  • Joined

  • Last visited

  • Days Won

    87

Everything posted by horst

  1. Just some thoughts: - but why can't they be real PW-users too? - You can create a specific role for them if you have other users (that not belong to the intranet) too. - You may create only one real user in PW, e.g. called 'intranet', and if the intranet-script returns valid user, you load/select this dummy-user. The real username you can store in $session. At least you are a bit rare with informations what the users should / need to do in PW, need they to be unique, do they need different roles / rights, or what else?
  2. Hi Manol, assuming you build a login page (frontend) in PW and ask for username and pass. Send it with your script to custom intranet DB, if result is true (valid user) you now can check if user already exists in PW, and if yes, select him. $users->setCurrentUser($users->get('username')); otherwise you can create him via API. I would handle all stuff in that login page.
  3. Hi Teppo. Very good site with good and usefull articles! I like that it is clean and has good readability. Also it seems to have some nice parts that needs further study. I also like how you advertise PW! Keep up with it ----- Does the Logo display correctly in Firefox (22.0)? (see screenshot) In http://www.flamingruby.com/blog/ready-set-launch/ is a show/hide TOC, but the links have no anchors in the doc (at least in my FF)?
  4. Ryan I simply have checked with disabled php_pdo_mysql it results to false and with enabled php_pdo_mysql it results to true The MySQL-Driver specific Constants are not known by the (base?) PDO-class. They are only known if the driver is installed.
  5. @Ryan: I have tried installing the latest dev version today. The Setup tested for PDO and says: ok! - but afterwards I saw that I haven't enabled it. So I haven't investigated further, but maybe it is better to do a more advanced checkin the routine: https://github.com/ryancramerdesign/ProcessWire/blob/dev/install.php#L152 like if(class_exists("PDO") && defined('PDO::MYSQL_ATTR_INIT_COMMAND')) { asking for class_exists('PDO') can result to true without installed php_pdo_mysql
  6. Thank's Ryan! I assumed that the pages only should excluded from the menu, but not from searches or maybe other lists (e.g. sitemap). But I only assumed that. I better first should ask for it, - what could save some coding, depending on the answer.
  7. I would really like something like a (maybe hidden) user named e.g. system or API or CLI that gets invoked for that (at least for bootstrapped scripts). It has confused me too in the past. Also if you create new pages that way, they get owned by "guest" in the system. Therefor I always try to log in first, when starting a bootstrapped instance. (But forget sometimes)
  8. Hi NoDice, this sounds for a use of Repeaters. Instead of creating 10 fields, you only need to create 1 field of each (image, caption, url) and create one repeater field that contains them. Afterwards you can create as much instances of the repeater as you need. In your case you also should add a checkbox field for enabled/disabled, I assume. As you already have much fields, you can start with enabling the repeater under SETUP-Modules if it isn't already. (Its a core-module but disabled by default) Then create a repeater field and assign your desired fields (one of each type). Last, add the repeater to your template. voila!
  9. Hi jacksprat, GD is not working! because the GD-function imagecreatefromjpeg isn't defined / available in server setup. Please check / enable GD-library for PHP.
  10. Hi Zahari, great there is some progress. Lets's look to the two issues now. And I once again want to say that I haven't used that profile, and I don't know it, - so if there is someone reading who knows it, come in and shed some light second one first: As the original code is written to render the navbar fast and straight forward, we have to hack in and rearrange parts and also first have to buffer the (optional) childrens output. This very fast can become cumbersome. Here is a version that you may try. I haven't tried it and I don't know if it works. If I understand the original code and assume it's relations right, it should work, but I don't know. function renderTopNav(PageArray $items, array $options = array(), $level = 0) { $defaults = array( 'tree' => 2, // number of levels it should recurse into the tree 'dividers' => true, 'repeat' => false, // whether to repeat items with children as first item in their children nav ); $options = array_merge($defaults, $options); $divider = $options['dividers'] ? "<li class='divider'></li>" : ""; $page = wire('page'); $out = ''; foreach($items as $item) { if($item->addtonavbar == 0) { continue; // should be excluded, so we skip and went to the next } $numChildren = $item->numChildren(true); if($level+1 > $options['tree'] || $item->id == 1) $numChildren = 0; $buffer = ''; // we need to buffer all children output if($numChildren) { $buffer2 = renderTopNav($item->children, $options, $level+1); if(strlen(trim($buffer2))>0) { $buffer = "<ul class='dropdown'>"; if($options['repeat']) $buffer .= "$divider<li><a href='$item->url'>$item->title</a></li>"; $buffer .= $buffer2; $buffer .= "</ul>"; } } $class = ''; if($numChildren && strlen($buffer)>0) $class .= "has-dropdown "; // parent gets dropdown-triangle if it has numchildren and the childrens-buffer isn't empty if($page->id == $item->id) $class .= "current "; if(($item->id > 1 && $page->parents->has($item)) || $page->id == $item->id) $class .= "active "; if($class) $class = " class='" . trim($class) . "'"; $out .= "$divider<li$class><a href='$item->url'>$item->title</a>"; $out .= $buffer; // buffer is an empty string or contains complete ul-list of children $out .= "</li>"; } return $out; } I think it is logical if you don't show a parent, you cannot show it's children. They belong together.
  11. Hi Zahari, welcome to the forums. Great you have found PW ;-) I assume you know how to add a checkbox-field to the templates (if not, please ask here again!) For example you may call this field "excludeFromTopnav" and after that you have to check in the foreach-loop in the function if the current item (what comes from an PageArray, so it is a $page) have this field checked or not: (Line 16) function renderTopNav(PageArray $items, array $options = array(), $level = 0) { $defaults = array( 'tree' => 2, // number of levels it should recurse into the tree 'dividers' => true, 'repeat' => false, // whether to repeat items with children as first item in their children nav ); $options = array_merge($defaults, $options); $divider = $options['dividers'] ? "<li class='divider'></li>" : ""; $page = wire('page'); $out = ''; foreach($items as $item) { if($item->excludeFromTopnav == 1) { continue; // should be excluded, so we skip and went to the next } $numChildren = $item->numChildren(true); if($level+1 > $options['tree'] || $item->id == 1) $numChildren = 0; $class = ''; if($numChildren) $class .= "has-dropdown "; if($page->id == $item->id) $class .= "current "; if(($item->id > 1 && $page->parents->has($item)) || $page->id == $item->id) $class .= "active "; if($class) $class = " class='" . trim($class) . "'"; $out .= "$divider<li$class><a href='$item->url'>$item->title</a>"; if($numChildren) { $out .= "<ul class='dropdown'>"; if($options['repeat']) $out .= "$divider<li><a href='$item->url'>$item->title</a></li>"; $out .= renderTopNav($item->children, $options, $level+1); $out .= "</ul>"; } $out .= "</li>"; } return $out; } So, not tested and I also haven't worked with the foundation profile, but it should work. Otherwise please come back here.
  12. https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/LanguageFunctions.php#L39 I think you can only split your text so that it doesn't contain HTML-tags. Also it isn't possible to write a wrapper function that does the splitting + translation + concatenation for you, because the translation-texts must be available in static form in code,
  13. Many thanks! Their site is currently not accessible for me, but I have found some good tutorial over its use. I will try again later.
  14. Hi, I have shown PW to a collegue of mine and now he is thinking about to use it for his website. Actually he sorts his needs, and there is one question: Has anybody already written (short) posts / texts in PW and pushed them to facebooks timeline? He don't like "work" in FB and pull that stuff into PW (what is already described here in forums). He would like it the other way round.
  15. Yeah, I think finally that hits the nail! Well, now there's more time for sudoku
  16. I think that must be done with ajax (so we are in DevTalk) with something like: while(onMouseOver('likeButton')) { hesitationCounter++; }
  17. LOL, no, it's just a try and error. I want to have members with more likes than posts counted up, but also want to honor much posts. But it doesn't do it with a simple linear ratio, because a member with only 1 or 2 posts and 15 likes beats all, also ryan with 3000 likes and 6000 posts. So I have tried to build a relation between the ratio and amount of the two parts. <german>Getreu dem Motto: "Trau keiner Statistik, es sei denn, du hast sie selbst gefälscht!"</german> <hopefully-correct-translation>Keeping with the motto: "Trust no statistics, unless you yourself have forged it!"</hopefully-correct-translation> YEP! no, it isn't that simple. oh, - you never have seen one of my sudokos I once only have played Gobang, a simple form of it. first point +1 second one: this would it make much more complex. And of course, than we also should take the profile-views into account? - or the posts per thread (in relation to the thread.length)?
  18. -------------------------------------------------------------------------------------------------------------------- EDIT (08.01.2014): finally a sortable Table is here: http://ranking.pw.nogajski.de/ (more info is here: http://processwire.com/talk/topic/5290-topposters-oldcode-more/) -------------------------------------------------------------------------------------------------------------------- Hi, I have not have a sudoku today, so I tried to create a Top-Posters-List that not rely only on the count of posts. But the line 41, where the ratio is calculated, needs to be corrected. If someone have a better math for it, please post it. <?php //---------------------------------------------------------------- GLOBAL CONFIG define('PW_MEMBERS_URL', 'http://processwire.com/talk/members/?sort_key=posts&sort_order=desc&max_results=60'); define('PW_MEMBERSLIST_PATTERN_1', "/<ul class='ipsMemberList'>(.*?)<script type='text\/javascript'>/msi"); define('PW_MEMBERSLIST_PATTERN_2', "/<li id='member_id_(.*?)'.*?<img src='(.*?)'.*?<\/ul>.*?<h3.*?<strong>(.*?)<\/strong>.*?<span class='number'>(.*?)<\/span>.*?·(.*?)post.*?<\/li>/msi"); //-------------------------------------------------------------- EXECUTABLE CODE $members = array(); $urls = array( PW_MEMBERS_URL, PW_MEMBERS_URL . '&st=60', PW_MEMBERS_URL . '&st=120', PW_MEMBERS_URL . '&st=180', PW_MEMBERS_URL . '&st=240' ); foreach($urls as $url) { $buffer = preg_match(PW_MEMBERSLIST_PATTERN_1, file_get_contents($url), $matches)===1 ? $matches[1] : null; if(is_null($buffer)) { echo "Something has going wrong with '$url'!"; exit(1); } if(60===preg_match_all("/<li id='member_id_(.*?)'.*?<img src='(.*?)'.*?<\/ul>.*?<h3.*?<strong>(.*?)<\/strong>.*?<span class='number'>(.*?)<\/span>.*?·(.*?)post.*?<\/li>/msi", $buffer, $temps, PREG_SET_ORDER)) { foreach($temps as $temp) { $likes = intval($temp[4]); $posts = intval(str_replace(',','', trim($temp[5]))); $member = array( 'id' => intval($temp[1]), 'name' => strip_tags($temp[3]), 'profile' => $temp[3], 'imgsrc' => $temp[2], 'likes' => $likes, 'posts' => $posts ); if(0==$likes) { $member['ratio'] = 0; // intval( $posts / 50 ); } else { $member['ratio'] = intval((($likes / $posts) * 100) * ($likes)) + intval($posts / 5); } $members[] = $member; } } } $members = hn_array_sort($members, array('ratio','likes','posts'), true, true); // the TOP 100 echo "<table border='0' cellpadding='0' cellspacing='5'>\n<tr><th>ratio</th><th>name</th><th>likes</th><th>posts</th></tr>\n"; for($i=0;$i<100;$i++) { $a = array_shift($members); echo "<tr><td>{$a['ratio']}</td><td>{$a['name']}</td><td>{$a['likes']}</td><td>{$a['posts']}</td></tr>\n"; } echo "</table>\n"; exit(0); //-------------------------------------------------------------------- FUNCTIONS /** Sorts the values of a given multidimensional Array in hirarchical order of the sortlist * @shortdesc USAGE: $SORTED_Array = hn_array_sort($orig_array, array('field3','field1','field2')); **/ function hn_array_sort($a, $sl, $intvals=false, $descending=false, $casesensitive=true) { $GLOBALS['__HN_SORTVALUE_LIST_DESCENDING__'] = $descending; $GLOBALS['__HN_SORTVALUE_LIST_CASESENSITIVE__'] = $casesensitive; $GLOBALS['__HN_SORTVALUE_LIST__'] = $sl; if($intvals===true) { usort($a, 'hn_cmp_Values_intvals'); } else { usort($a, 'hn_cmp_Values_strvals'); } return $a; } // Callback for hn_array_sort() function hn_cmp_Values_strvals($a, $b) { foreach($GLOBALS['__HN_SORTVALUE_LIST__'] as $f) { $strc = $GLOBALS['__HN_SORTVALUE_LIST_CASESENSITIVE__']===true ? strcmp($a[$f],$b[$f]) : strcasecmp($a[$f],$b[$f]); if($strc != 0) { if($GLOBALS['__HN_SORTVALUE_LIST_DESCENDING__']===true) { return $strc * (-1); } return $strc; } } return 0; } // Callback for hn_array_sort() function hn_cmp_Values_intvals($a, $b) { foreach($GLOBALS['__HN_SORTVALUE_LIST__'] as $f) { if(intval($a[$f])===intval($b[$f])) { $intc = 0; } elseif(intval($a[$f])>intval($b[$f])) { $intc = $GLOBALS['__HN_SORTVALUE_LIST_DESCENDING__']===true ? -1 : 1; } else { $intc = $GLOBALS['__HN_SORTVALUE_LIST_DESCENDING__']===true ? 1 : -1; } if($intc !== 0) return $intc; } return 0; } EDIT: replaced the Line 41 with a new more suitable formula
  19. Here is code from Ryan in a post of this thread: // Run photo upload foreach($files as $filename) { $pathname = $upload_path . $filename; $np->contact_photo->add($pathname); $np->message("Added file: $filename"); unlink($pathname); // This deletes the uploaded file after it was added to the new page ($np) } unlink(); If you work with another code, you also add the files to the page. After that you have to unlink('the temp-file');
  20. Without knowing how, I can say yes. Because Somas Modules Manager exists and it knows all of my installed Modules. (Sorry for beeing not much of help)
  21. good and clear design! "Buchungsanfrage" isn't completly implemented? When trying I don't get a list of rooms or calendars.
  22. No sorry, I don't know it, - but I once again recommend to post this into the support board of the module. This way there is a big chance that the modules author read it and can respond to it. (thats why the support board exists!)
  23. Hi seedle, welcome to the forums. I think you should post that to the support board of the module. This way there is a big chance that the modules author read it and can respond to it. I haven't integrated third party programms into PW myself, but I think it could be more work to do than to get the discussion module running. But I'm not sure on this.
  24. This definetly sounds to some sort of filesystem permission. Have you turned debug on and there are error-logs? Do you have a look into Browser-Console (JS, Network), because upload is ajax-based. sounds like filesystem permission too! (Session-files) You also need to check Apache logs. Has the server software changed 7 days ago? Or if it is a hosted account, was the account moved? ---- Also, don't know if it is relevant here, you have in PHP-settings upload_max_filesize 2M and post_max_size 8M, - not that much.
  25. You can use scripts in commandline mode or in HTTP environment that include the pw index.php like this for example: // the absolute path or relative path to processwires index.php $PATH2PWindex = dirname(__FILE__).'/index.php'; // $username and $pass to a superuser $PWuser = ''; $PWpass = ''; // ... require_once($PATH2PWindex); wire('session')->login($PWuser,$PWpass); if(!wire('user')->active || !wire('user')->hasRole('superuser')) { echo "\n\nERROR: Incorrect UserLogin!\n\nScript stop now!\n"; exit(1); } after that you are logged in as superuser and can do all API stuff you like. I use this above as external CLI-Script and ask for credentials in shell window. You have to access the API via wire('pages'), wire('session'), etc instead of $pages or $session. http://processwire.com/api/include/
×
×
  • Create New...