Exemplo n.º 1
0
 /**
  * One stop shop for adding activate/deactivate functionality to your ActiveRecord
  *
  * @param ActiveRecord object that has 'active' in its table
  */
 public static function activatorImage($ARobject, $opts = NULL)
 {
     global $siteDomain;
     if (!is_null($opts)) {
         extract($opts);
         if ($success) {
             $success = ", " . $success;
         }
     }
     if (!in_array('active', array_keys($ARobject->getColumns()))) {
         throw new Exception('This object does not have an \'active\' column.');
     }
     if (AccelObject::backend()) {
         $activeToggleUrl = "http://" . ThemeHelper::singleton()->siteDomain() . "/accelsite/admin/?adminAction=activeToggle&adminLayout=empty";
     } else {
         $activeToggleUrl = "/?ado=genericActiveToggle&layout=empty";
     }
     $js = "\n        \$('.activeToggle').click(function() {\n            \$(this).html('" . str_replace('\'', '\\\'', self::adminIcon('activeToggleLoader')) . "');\n            \$(this).load('{$activeToggleUrl}&ajax=true&activeToggle=' + \$(this).attr('myID') + '&toggleClass=' + \$(this).attr('myClass') {$success});\n            return false;\n        });";
     AccelJS::findThis()->ready($js);
     return "<a href='#' myID='" . $ARobject->id() . "' myClass='" . $ARobject->getClass() . "' class='activeToggle'>" . self::activeImage($ARobject->active()) . "</a>";
 }