Created
October 27, 2012 22:02
-
-
Save asanchez75/3966560 to your computer and use it in GitHub Desktop.
AA_Stringexpand scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AA_Stringexpand_Eval extends AA_Stringexpand { | |
function expand($code) { | |
ob_start(); | |
print eval('?>' . $code); | |
$output = ob_get_contents(); | |
ob_end_clean(); | |
return $output; | |
} | |
} | |
class AA_Stringexpand_ArrayNodes extends AA_Stringexpand { | |
function expand($slice_id, $fieldalias) { | |
$AA_ids = new AA_Stringexpand_ids(); | |
$ids = $AA_ids->expand($slice_id); | |
$nids = explode('-', $ids); | |
foreach ($nids as $nid) { | |
$AA_item = new AA_Stringexpand_Item(); | |
$fieldvalue = $AA_item->expand($nid, $fieldalias); | |
$nodes[] = $fieldvalue; | |
} | |
return $nodes; | |
} | |
} | |
class AA_Stringexpand_TagsCount extends AA_Stringexpand { | |
function expand() { | |
$tagscloud = array(); | |
$max_count = 0; | |
// change scale font | |
$scale_font = 30; | |
$ids = new AA_Stringexpand_ArrayNodes(); | |
// slice 4. Palabras clave | |
$array_ids = $ids->expand('0fcd5dc7f9da6473fd9efad662dfe531', '_#ITEM_ID_'); | |
$resources = new AA_Stringexpand_ArrayNodes(); | |
// slice 5. Banco de Materiales de Formacion | |
// _#PALABRC2 contains ids separated by '-' | |
$array_resources = $resources->expand('f240a615da76cae02493aac79b0a7da9', '_#PALABRC2'); | |
foreach ($array_ids as $id) { | |
$AA_item = new AA_Stringexpand_Item(); | |
$tag = $AA_item->expand($id, '_#HEADLINE'); | |
$i = 0; | |
foreach ($array_resources as $resource) { | |
$ids = explode('-', $resource); | |
foreach ($ids as $idf) { | |
$AA_item = new AA_Stringexpand_Item(); | |
$value = $AA_item->expand($idf, '_#HEADLINE'); | |
if(strtolower($tag) == strtolower($value)) { | |
$i++; | |
$terms[$idf]['count'] = $i; | |
$terms[$idf]['id'] = $id; | |
$terms[$idf]['name'] = $tag; | |
} | |
} | |
} | |
$max_count = max($max_count, $terms[$id]['count']); | |
// this $id is the same that $idf but is better to access to array key for getting values from loop | |
$cloud = new AA_Stringexpand_Theme(); | |
$tagscloud[] = $cloud->expand('link', array('url' => '/apc-aa/view.php3?vid=19&cmd[19]=c-1-' . $terms[$id]['id'], 'text' => $terms[$id]['name'] . ' (' . $terms[$id]['count'] . ')', 'attributes' => array('style' => 'font-size: ' . $scale_font*($terms[$id]['count'] / $max_count) . 'pt;'))); | |
} | |
return implode('-', $tagscloud) . $total; | |
} | |
} | |
class AA_Stringexpand_Theme extends AA_Stringexpand { | |
function expand($themename, $variables) { | |
switch ($themename) { | |
case 'link': | |
$html = '<a href="' . $variables['url'] . '"' . AA_attributes($variables['attributes']) .'>' . $variables['text'] . '</a>'; | |
break; | |
default: | |
# code... | |
break; | |
} | |
return $html; | |
} | |
} | |
function AA_attributes(array $attributes = array()) { | |
foreach ($attributes as $attribute => &$data) { | |
$data = implode(' ', (array) $data); | |
$data = $attribute . '="' . $data . '"'; | |
} | |
return $attributes ? ' ' . implode(' ', $attributes) : ''; | |
} | |
function arreglo($item) { | |
static $items; | |
$items[] = $item; | |
return $items; | |
} | |
======================================================================================== | |
class AA_Stringexpand_Stars extends AA_Stringexpand { | |
function expand($item_id, $field_id_total_sum, $field_id_total_clicks) { | |
//print_r($item_id); | |
//print_r($field_id_total_sum); | |
$db = new DB_AA(); | |
$db->query("SELECT * FROM content WHERE item_id = UNHEX('" . $item_id . "') AND field_id = '" . $field_id_total_sum . "'"); | |
$field_total_sum_value = $db->next_record() ? $db->f('text') : ""; | |
$db->query("SELECT * FROM content WHERE item_id = UNHEX('" . $item_id . "') AND field_id = '" . $field_id_total_clicks . "'"); | |
$field_total_clicks_value = $db->next_record() ? $db->f('text') : ""; | |
print_r($field_total_clicks_value); | |
$form .= "<form>" ; | |
$form .= "<input type=radio name=\"star\" value=\"1\" onclick=\"alert('hola')\">" ; | |
$form .= "<input type=radio name=\"star\" value=\"2\">" ; | |
$form .= "<input type=radio name=\"star\" value=\"3\">" ; | |
$form .= "<input type=radio name=\"star\" value=\"4\">" ; | |
$form .= "<input type=radio name=\"star\" value=\"5\">" ; | |
$form .= "</form>" ; | |
return $form; | |
} | |
} | |
/*******EJEMPLO DE USO DE {eval:}**********/ | |
FILAS IMPARES | |
{Eval: | |
<?php | |
global $items; | |
$items = arreglo({_#HEADLINE}); | |
?> | |
} | |
PIE HTML | |
{Eval: | |
<?php | |
global $items; | |
foreach ($items as $item) { | |
print substr($item,0,5) . ' ************ '; | |
} | |
?> | |
===== | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment