function searchItem($arr) { global $page; foreach ($arr as $name => $content) { if ($content === $page) { return array(array($name), $name); } else { if (is_array($content)) { $res = searchItem($content); if (count($res) === 2) { array_push($res[0], $name); return array($res[0], $res[1]); } } } } return array(); }
function aa_admin_import_page() { global $keyword, ${$selectedSearchIndex}, $itempage; $appid = get_option('dbaa_amazon_appid'); $coutryCode = get_option('dbaa_amazon_coutnrycode'); $secretKey = get_option('dbaa_amazon_secretkey'); $associatetag = get_option('dbaa_amazon_associatetag'); if ($appid == '' || $coutryCode == '' || $secretKey == '') { echo '<H2>Bitte gehen Sie zu den Einstellungen und geben Sie Ihre Daten zur Kommunikation mit der Amazon Api ein.</H2>'; } else { $defaultOptions = array('AssociateTag' => $associatetag, 'ResponseGroup' => 'Small, OfferFull, ItemAttributes, Images, Variations'); $amazon = new Zend_clicks_Service_Amazon($appid, $coutryCode, $secretKey); $itemResults = array(); if ($_REQUEST['action'] == 'search' && !empty($_POST['keyword']) && empty($_POST['asin'])) { $keyword = $_POST['keyword']; $selectedSearchIndex = $_POST['searchIndex']; $itempage = 1; $options = array('SearchIndex' => $selectedSearchIndex, 'Keywords' => $keyword, 'ItemPage' => $itempage); $options = array_merge($options, $defaultOptions); $itemResults = $amazon->itemSearch($options); } elseif ($_REQUEST['action'] == 'search' && empty($_POST['keyword']) && !empty($_POST['asin'])) { $asin = $_POST['asin']; $selectedSearchIndex = $_POST['searchIndex']; $itemResults = $amazon->itemLookup($asin, $defaultOptions); } elseif ($_REQUEST['action'] == 'back' && !empty($_POST['itempage']) || $_REQUEST['action'] == 'next' && !empty($_POST['itempage'])) { $keyword = $_POST['keyword']; $selectedSearchIndex = $_POST['searchIndex']; $itempage = $_POST['itempage']; $options = array('SearchIndex' => $selectedSearchIndex, 'Keywords' => $keyword, 'ItemPage' => $itempage); $options = array_merge($options, $defaultOptions); $itemResults = $amazon->itemSearch($options); } elseif ($_REQUEST['action'] == 'save' && !empty($_POST['title'])) { if (saveItem($_POST)) { echo '<div class="updated"><p><strong>Produkt erfolgreich importiert</strong></p></div>'; } } echo '<h2>Produkte importieren</h2>'; searchItem($keyword, $asin, $selectedSearchIndex, $itempage); // Suchformular einblenden; foreach ($itemResults as $result) { formatResult($result); } } }
<link rel = 'stylesheet' href = 'css/form.css'> <link rel = 'stylesheet' href = 'css/account.css'> <link rel = 'stylesheet' href = 'css/search.css'> </head> <body> <div id = 'wrapper'> <?php headerAndSearchCode(); ?> <?php right_bar(); ?> <section id = 'right_side'> <?php searchItem(); ?> </section> <?php footerCode(); ?> </div> </body> </html>
function showProfile($expert, $req, $sysSkills, $sysQualif, $assessmentsAsOutput = FALSE) { /** */ global $debugar; //$profile = getCandidateProfile($userid); if ($debugar) { echo '<p>Expert:<pre>' . print_r($expert, TRUE) . '</pre>'; } $profile = $expert['profile']; //$content = '<br />Profile: <pre>'.print_r($profile, TRUE). '</pre>'; $content .= '<ul>'; // =========================================================================== // Skills $names = $sysSkills; $title = 'Required skills'; $item = 'skills'; $content .= '<li><em>' . $title . '</em>: '; $c_skills = ''; $i = 0; foreach ($profile[$item] as $skill) { $content_skill = ''; $i = $i + 1; $requerida = FALSE; if (searchItem($req[$item], 'id', $skill['id']) >= 0) { $requerida = TRUE; } if ($requerida) { $content_skill .= '<strong>'; } // Name of the skill $content_skill .= nombreSkill($skill['id'], $names); if ($requerida) { $content_skill .= '</strong>'; } $content_skill .= ' (' . $skill['level'] . ')'; // Si hay mas, ponemos una coma. Si no, un punto. //if ($i < count($profile[$item])) { // $content_skill .= ', '; //} else { // $content_skill .= '.'; //} // Solo mostramos los requeridos, para evitar filas muy altas con perfiles largos if ($requerida) { if ($c_skills != '') { $c_skills .= ', '; } $c_skills .= $content_skill; } } // End foreach if ($c_skills == '') { $c_skills = 'none of the required'; } $content .= $c_skills . '.'; $content .= '</li>'; // =========================================================================== // Subskills $names = $sysQualif; $title = may1a(STRING_SUBSKILLS); $item = STRING_SUBSKILLS; $content .= '<li><em>' . $title . '</em>: '; $i = 0; foreach ($profile[$item] as $skill) { $i = $i + 1; $requerida = FALSE; //if (array_key_exists($item, $req)) { // if (searchItem(array_values($req[$item]), 'id', $skill) >= 0) { // $requerida = TRUE; // } //} if (searchItem($req[$item], 'id', $skill['id']) >= 0) { $requerida = TRUE; } if ($requerida) { $content .= '<strong>'; } // Name of the skill $content .= nombreSkill($skill['id'], $names); if ($requerida) { $content .= '</strong>'; } // Si hay mas, ponemos una coma. Si no, un punto. if ($i < count($profile[$item])) { $content .= ', '; } else { $content .= '.'; } } $content .= '</li>'; // =========================================================================== // Availability $title = 'Availability'; $item = 'availability'; $content .= '<li><em>' . $title . '</em>: '; $av = $profile[$item]; switch ($av) { case 1: $txtAv = 'fully available'; break; case 0: $txtAv = 'do not disturb'; break; default: $txtAv = 'medium'; break; } $content .= $txtAv . '</li>'; // Assessments //if ($debugar) { if (!$assessmentsAsOutput) { // If $assessmentsAsOutput, avoid to output assessments in the profile $content .= '<li>Assessments (debug mode): <pre>' . print_r($expert['assessments'], TRUE) . '</pre></li>'; } //} $content .= '</ul>'; if (!$assessmentsAsOutput) { // Just return html content return $content; } else { // Return both content and assessments return array($content, $expert['assessments']); } }