1
0

Code Cleanup, comments, etc.

Signed-off-by: Tim Almdal <tnalmdal@shaw.ca>
This commit is contained in:
rWatcher 2009-07-13 10:55:47 +08:00 committed by Tim Almdal
parent 250c6037aa
commit 96604083ec
6 changed files with 70 additions and 16 deletions

View File

@ -33,9 +33,13 @@ class Admin_EmbedLinks_Controller extends Admin_Controller {
// Figure out which boxes where checked
$linkOpts_array = Input::instance()->post("LinkCodeTypeOptions");
$displayType_array = Input::instance()->post("LinkDisplayType");
$HTMLButton = false;
$BBCodeButton = false;
$InPageLinks = false;
$DialogLinks = false;
for ($i = 0; $i < count($linkOpts_array); $i++) {
if ($linkOpts_array[$i] == "HTMLCode") {
$HTMLButton = true;
@ -43,11 +47,21 @@ class Admin_EmbedLinks_Controller extends Admin_Controller {
if ($linkOpts_array[$i] == "BBCode") {
$BBCodeButton = true;
}
}
for ($i = 0; $i < count($displayType_array); $i++) {
if ($displayType_array[$i] == "InPageLinks") {
$InPageLinks = true;
}
if ($displayType_array[$i] == "DialogLinks") {
$DialogLinks = true;
}
}
// Save Settings.
module::set_var("embedlinks", "HTMLCode", $HTMLButton);
module::set_var("embedlinks", "BBCode", $BBCodeButton);
module::set_var("embedlinks", "InPageLinks", $InPageLinks);
module::set_var("embedlinks", "DialogLinks", $DialogLinks);
message::success(t("Your Selection Has Been Saved."));
// Load Admin page.
@ -66,10 +80,16 @@ class Admin_EmbedLinks_Controller extends Admin_Controller {
$linkCodes["HTMLCode"] = array("Show HTML Links", module::get_var("embedlinks", "HTMLCode"));
$linkCodes["BBCode"] = array("Show BBCode Links", module::get_var("embedlinks", "BBCode"));
// Make an array for the different methods of displaying the links.
$linkDisplays["InPageLinks"] = array("Show Links In The Actual Page", module::get_var("embedlinks", "InPageLinks"));
$linkDisplays["DialogLinks"] = array("Show Links In a Seperate Dialog Box", module::get_var("embedlinks", "DialogLinks"));
// Setup a few checkboxes on the form.
$add_links = $form->group("EmbedLinks");
$add_links->checklist("LinkCodeTypeOptions")
->options($linkCodes);
$add_links->checklist("LinkDisplayType")
->options($linkDisplays);
// Add a save button to the form.
$add_links->submit("SaveSettings")->value(t("Save"));

View File

@ -22,24 +22,31 @@ class EmbedLinks_Controller extends Controller {
* Display the EXIF data for an item.
*/
public function showhtml($item_id) {
// Generate the Dialog Box for HTML links.
$item = ORM::factory("item", $item_id);
access::required("view", $item);
// If the current page is an album, only display two links,
// or else display many.
if ($item->is_album()) {
$linkArray[0] = array("Text:", "<a href=&quot;" . url::abs_site("{$item->type}s/{$item->id}") . "&quot;>Click Here</a>");
$linkArray[1] = array("Thumbnail:", "<a href=&quot;" . url::abs_site("{$item->type}s/{$item->id}") . "&quot;><img src=&quot;" . $item->thumb_url(true) . "&quot;></a>");
$linkTitles[0] = array("Link To This Album:", 2);
} else {
// Link to the current page.
$linkArray[0] = array("Text:", "<a href=&quot;" . url::abs_site("{$item->type}s/{$item->id}") . "&quot;>Click Here</a>");
$linkArray[1] = array("Thumbnail:", "<a href=&quot;" . url::abs_site("{$item->type}s/{$item->id}") . "&quot;><img src=&quot;" . $item->thumb_url(true) . "&quot;></a>");
$linkArray[2] = array("Resized:", "<a href=&quot;" . url::abs_site("{$item->type}s/{$item->id}") . "&quot;><img src=&quot;" . $item->resize_url(true) . "&quot;></a>");
$linkTitles[0] = array("Link To This Page:", 3);
// Link to the "resized" version of the current image.
$linkArray[3] = array("Text:", "<a href=&quot;" . $item->resize_url(true) . "&quot;>Click Here</a>");
$linkArray[4] = array("Thumbnail:", "<a href=&quot;" . $item->resize_url(true) . "&quot;><img src=&quot;" . $item->thumb_url(true) . "&quot;></a>");
$linkArray[5] = array("Image:", "<img src=&quot;" . $item->resize_url(true) . "&quot;>");
$linkTitles[1] = array("Link To The Resized Image:", 3);
// If the visitor has suficient privlidges to see the fullsized
// version of the current image, then display links to it.
if (access::can("view_full", $item)) {
$linkArray[6] = array("Text:", "<a href=&quot;" . $item->file_url(true) . "&quot;>Click Here</a>");
$linkArray[7] = array("Thumbnail:", "<a href=&quot;" . $item->file_url(true) . "&quot;><img src=&quot;" . $item->thumb_url(true) . "&quot;></a>");
@ -55,24 +62,31 @@ class EmbedLinks_Controller extends Controller {
}
public function showbbcode($item_id) {
$item = ORM::factory("item", $item_id);
// Generate the Dialog Box for BBCode links.
$item = ORM::factory("item", $item_id);
access::required("view", $item);
// If the current page is an album, only display two links,
// or else display many.
if ($item->is_album()) {
$linkArray[0] = array("Text:", "[url=" . url::abs_site("{$item->type}s/{$item->id}") . "]Click Here[/url]");
$linkArray[1] = array("Thumbnail:", "[url=" . url::abs_site("{$item->type}s/{$item->id}") . "][img]" . $item->thumb_url(true) . "[/img][/url]");
$linkTitles[0] = array("Link To This Album:", 2);
} else {
$linkArray[0] = array("Text:", "[url=" . url::abs_site("{$item->type}s/{$item->id}") . "]Click Here[/url]");
// Link to the current page.
$linkArray[0] = array("Text:", "[url=" . url::abs_site("{$item->type}s/{$item->id}") . "]Click Here[/url]");
$linkArray[1] = array("Thumbnail:", "[url=" . url::abs_site("{$item->type}s/{$item->id}") . "][img]" . $item->thumb_url(true) . "[/img][/url]");
$linkArray[2] = array("Resized:", "[url=" . url::abs_site("{$item->type}s/{$item->id}") . "][img]" . $item->resize_url(true) . "[/img][/url]");
$linkTitles[0] = array("Link To This Page:", 3);
// Link to the "resized" version of the current image.
$linkArray[3] = array("Text:", "[url=" . $item->resize_url(true) . "]Click Here[/url]");
$linkArray[4] = array("Thumbnail:", "[url=" . $item->resize_url(true) . "][img]" . $item->thumb_url(true) . "[/img][/url]");
$linkArray[5] = array("Image:", "[img]" . $item->resize_url(true) . "[/img]");
$linkTitles[1] = array("Link To The Resized Image:", 3);
// If the visitor has suficient privlidges to see the fullsized
// version of the current image, then display links to it.
if (access::can("view_full", $item)) {
$linkArray[6] = array("Text:", "[url=" . $item->file_url(true) . "]Click Here[/url]");
$linkArray[7] = array("Thumbnail:", "[url=" . $item->file_url(true) . "][img]" . $item->thumb_url(true) . "[/img][/url]");

View File

@ -19,20 +19,40 @@
*/
class embedlinks_theme_Core {
static function sidebar_blocks($theme) {
if ($theme->item()->is_album()) {
// If the current item is an album and if "In Page" links are enabled then
// display links to the current album in the theme sidebar.
if ($theme->item()->is_album() && module::get_var("embedlinks", "InPageLinks")) {
$block = new Block();
$block->css_id = "gMetadata";
$block->title = t("Links");
$block->content = new View("embedlinks_album_block.html");
return $block;
}
}
static function sidebar_bottom($theme) {
// If displaying links in a dialog box is enabled then
// insert buttons into the bottom of the side bar
// to open up the dialog window.
if (module::get_var("embedlinks", "DialogLinks")) {
$block = new Block();
$block->css_id = "gMetadata";
$block->title = t("Link To This Page:");
$block->content = new View("embedlinks_sidebar.html");
return $block;
}
}
static function photo_bottom($theme) {
$block = new Block();
$block->css_id = "gMetadata";
$block->title = t("Links");
$block->content = new View("embedlinks_photo_block.html");
return $block;
static function photo_bottom($theme) {
// If the current item is a photo and displaying "In Page" links
// is enabled, then insert HTML/BBCode links into the bottom
// of the page.
if (module::get_var("embedlinks", "InPageLinks")) {
$block = new Block();
$block->css_id = "gMetadata";
$block->title = t("Links");
$block->content = new View("embedlinks_photo_block.html");
return $block;
}
}
}

View File

@ -20,5 +20,5 @@
<? $counter+= $titles[$i][1]; ?>
</tbody>
</table>
<? endfor ?>
<? endfor ?>
</div>

View File

@ -20,5 +20,5 @@
<? $counter+= $titles[$i][1]; ?>
</tbody>
</table>
<? endfor ?>
<? endfor ?>
</div>

View File

@ -3,7 +3,7 @@
<a href="<?= url::site("embedlinks/showhtml/{$item->id}") ?>" title="<?= t("HTML Links") ?>"
class="gDialogLink gButtonLink ui-icon-left ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-info"></span>
<?= t("HTML Code") ?>
<?= t("Show HTML Code") ?>
</a><br />
<? } ?>
@ -11,6 +11,6 @@
<a href="<?= url::site("embedlinks/showbbcode/{$item->id}") ?>" title="<?= t("BBCode Links") ?>"
class="gDialogLink gButtonLink ui-icon-left ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-info"></span>
<?= t("BBCode") ?>
<?= t("Show BBCode") ?>
</a>
<? } ?>